GUIs don't support text with a '£' when set via script

I was working on a side project a few weeks ago and came across a frustrating bug involving the £ sign.

The project was a quick clone of Deal or No Deal, and the amounts are in GBP. The amounts are set randomly by a script, but when I add the cash manually this is what is shown:

The script adds the numbers randomly from a table and concatenates a ‘£’ in front of the amount. However, nothing is displayed on the TextLabel but the text is there but with a “missing character” symbol or whatever it is.

I’m not actively working on this game anymore but the bug is quite annoying to people in the UK who might want to use the £ symbol.

This bug also occurs with any kind of GUI object, Surface, Billboard, Screen etc.

If I remember correctly, scripts don’t support UTF8 at all. All UTF8 characters become the unknown character you see in the Text property, and I believe this is only visible after you close and open the editor.

1 Like

You can use string.char(163) as an alternative to writing '£' in your code.

2 Likes

Ahh, I guess this probably will never change then.

but this sounds like a neat workaround thanks :smiley:

Let me know if it works though, I’m actually not entirely sure

That didn’t work when I tried it. Neither did “\163”. Roblox puts the character 194, or Â, in front of £ in the text to display it, so putting £ should work.

1 Like

Alas it did not :frowning:

So then maybe try something like this as @MettaurSp mentions:

(...).Text = string.char(194) .. string.char(163) .. "1000"

This seems to work for me, I’m a bit confused atm why it wants the 194 char there specifically though. If any character I’d expect something more predictable there rather than a seemingly random value.

This seems to work, awesome.
Its a mystery to me as to why you would need to add that character in order for £ to show.

It is just the way Roblox GUI objects encode text. Both of those characters are outside of the printable ASCII character range (32-127) so they are “safe” to use for special encoding purposes and extend the range of characters past 255. Roblox Studio recognizes that you want to have the encoded version when you put it in a field in the properties, but it assumes you know what you are doing in the script editor. Some users may use specific characters for special behavior in their scripts, so inserting an extra character just for the sake of encoding for GUI text objects alone would be unexpected behavior in many cases.

1 Like

Right, so the pound sign is U+00A3 in unicode, but in UTF-8 it would map to C2A3 as a two-byte sequence rather than one byte. C2 = 194, A3 = 163.

163 on its own does not belong to any character in UTF-8, so if you just fill out 163 on its own it will result in a non-printable character. The 194 byte is associated with a 2-byte character, so if you put 194 followed by a 163 it will be interpreted as the correct two-byte character.

2 Likes

Studio should use UTF-8 for scripts so that this is not an issue… cc @Silent137

1 Like

I spent some time trying to reproduce this issue and I could not.

I believe that our recent conversion to the latest version of Qt (a UI layer that lets us deploy on both Mac and Windows) has fixed the issue.

Can you confirm?