String turning into "?" but why?


#1

Hello, I’m working on a little tool and I’m running a bit of code and I’m running into an issue where there is something (that I’m not aware of) in line 12 is making the whole string turn into “??”. I was wondering what could be causing this/how to fix it. Here is the code bit of code I’m running.

file_data.push_str(
"
install:
before_build:
build_script:

on_success:
  - ps: |
    Remove-item alias:curl
    cd $($env:BUILD_DIRECTORY)
    7z a -r build.zip ./
    $buildLink       = [string](curl --silent --upload-file .\build.zip https://transfer.sh/build.zip)
    $appveyor_branch = \"[$($env:APPVEYOR_REPO_BRANCH)]\"
    $ci_name         = \"[AppVeyor]\"
    $os_name         = \"[Windows]\"
    $compiler        = \"[$($env:COMPILER)]:%20\"
    $pass            = \"#$($env:APPVEYOR_BUILD_NUMBER)%20PASSED\"
    $card_name       = \"name=$($appveyor_branch)$($ci_name)$($os_name)$(compiler)$(pass)\"
    $additional_data = \"&due=null&pos=top\"
    $description     = \"&desc=\\[Build\\]:%20$($buildLink)%0D\\[Logs\\]:%20https://ci.appveyor.com/project/$($env:APPVEYOR_REPO_NAME)/build/$($env:APPVEYOR_BUILD_VERSION)/job/$($env:APPVEYOR_JOB_ID)
    $trello_data     = \"&idList=$($env:TRELLO_API_LIST_ID)&idLabels=$($env:TRELLO_API_BUILD_PASS_ID)&token=$($env:TRELLO_APP_TOKEN)&key=$($env:TRELLO_API_KEY)\"
    $data            = \"$($env:card_name)$($env:additional_data)$($env:description)$($env:trello_data)\"
    curl -s --data $($data) https://api.trello.com/1/cards > $null

  on_failure:
    - ps: |
    Remove-item alias:curl
    $appveyor_branch = \"[$($env:APPVEYOR_REPO_BRANCH)]\"
    $ci_name         = \"[AppVeyor]\"
    $os_name         = \"[Windows]\"
    $compiler        = \"[$($env:COMPILER)]:%20\"
    $pass            = \"#$($env:APPVEYOR_BUILD_NUMBER)%20PASSED\"
    $card_name       = \"name=$($appveyor_branch)$($ci_name)$($os_name)$(compiler)$(pass)\"
    $additional_data = \"&due=null&pos=top\"
    $description     = \"&desc=\\[Logs\\]:%20https://ci.appveyor.com/project/$($env:APPVEYOR_REPO_NAME)/build/$($env:APPVEYOR_BUILD_VERSION)/job/$($env:APPVEYOR_JOB_ID)
    $trello_data     = \"&idList=$($env:TRELLO_API_LIST_ID)&idLabels=$($env:TRELLO_API_BUILD_PASS_ID)&token=$($env:TRELLO_APP_TOKEN)&key=$($env:TRELLO_API_KEY)\"
    $data            = \"$($env:card_name)$($env:additional_data)$($env:description)$($env:trello_data)\"
    curl -s --data $($data) https://api.trello.com/1/cards > $null
");

#2

There’s nothing in that code to suggest why that would happen. There’s also nothing in Rust that I can think of that could cause that. You’re probably going to need to build a reproducible example.


#3

I made a program with just this bit of code and it ended up being that \b is an unknown character escape (which causes the compiler to give an error). The issue would now be that in my usage case the compiler isn’t catching that…


#4

You might want to have a look at so called raw string literals in the language reference. This will save you the pain of quoting all quotes as ". :slightly_smiling:

If you think, the compiler has a bug, you might also want to file a ticket at the rust-github repository with a simplified code snippet.