I want to get the outside temperature into a variable.
curl wttr.in/berlin?format=%t
produces a perfect clean output of, for example +8°C (at command prompt) that I'd like. %t is for temperature. however this
curl wttr.in/berlin?format=%t>temp.txt
set /p temp=<temp.txt
produces -7┬░C which I don't like. I just wonder if I could fix this for command instead and skip the character set problem
for /f %%x in ('curl wttr.in/berlin?format=%t') do set temp=%%x
but this one suddenly produces general multirow result instead of just the simple temperature, along with error
Could not resolve host: %t
ultimately I will need multiple variables from wttr.in so it would be most efficient to extract them all at once, and set variables accordingly, for example
curl wttr.in/berlin?format="%t+%C+%w"
where %C is conditions, %w is wind. does this mean that fixing the for loop is the way to go for simplicity?
Forloop, changeformat=%ttoformat^=%%t. BTW, in your previous code example,set /p temp=temp.txtshould have readset /p temp=<temp.txt.for /f "delims=" %%a in ('"curl wttr.in/berlin?format="%%t+%%C+%%w""') do echo %%afixes yourforproblem. No solution for the weird characters though.curlreturns a Unicode string. Writing it to an ASCII file "translates" the two Unicode bytes of°into two bytes.°Cpart anyhow, surely you only need the number, the rest can be added manually if required in later output.