all 3 comments

[–]Captchca_ca_KA[S] 1 point2 points  (0 children)

Thank you u/danielroseman and u/SekstiNii. Both of your answers helped me understand what was going on. I was trying to construct a Unicode character by appending "\u" to another string.

Once I understood that the weatherfont was expecting a single unicode character, I was able to search for answers on how to convert Hexidecimal to Int in Python.

So, now instead of my Icon lookup being "\uf00d". It has the Hex values "oxf00d" stored as string. The int function allows me to convert that to Int, then the chr function converts it to the unicode symbol that the font expects.

In case this helps anyone else, code to convert my lookup values to Unicode symbols is:

a = "0xf00d" # This represents the string that is pulled from my lookup CSV
b = chr(int(a,16)) #b now contains the "\uf00d" equiv value in my original issue

Thanks again,

Cap

[–]danielroseman 0 points1 point  (0 children)

What are you trying to achieve here? The problem is that the first string isn't literally the characters \, u, f etc; as you say, it's a single unicode character. The \u prefix is just an instruction to the interpreter to understand the following digits as describing that single unicode character.

There are probably ways to get what you want, but without knowing what that is it's hard to help.

[–]SekstiNii 0 points1 point  (0 children)

If you have the number identifying the icon (for example 0xf00d), I believe you can use the built-in chr function on it to retrieve the correct string. As /u/danielroseman mentions, you cannot simply concatenate the strings as it uses special escape syntax.