Issues with double quotes

,

When trying to display double quotes (“ 0x201C and ” U+201D, not " 0x22) they require escaping which isn't the case in base lua 5.2. That is fine but the issue I have is that they are then converted into a standard quote (0x22)

string.byte("\"") == string.byte("\“") -- Equates to true

This means that even if your font has the correct sprites and you load the text in from a file they are treated as null but still have different string.byte representations. L“R” apparently has 8 characters:

15:23:18: 76
15:23:18: L

15:23:18: 226
15:23:18: (null)

15:23:18: 128
15:23:18: (null)

15:23:18: 156
15:23:18: (null)

15:23:18: 82
15:23:18: R

15:23:18: 226
15:23:18: (null)

15:23:18: 128
15:23:18: (null)

15:23:18: 157
15:23:18: (null)

Yeah, when we load the text from a source file we automatically translate the smart quotes to plain so they don't confuse the compiler. Did Lua 5.2 handle that? I know 5.3 and 5.4 don't.. I'm not sure what you mean about loading the text in from a file. If you've got L“R” in a file encoded as UTF-8 then load it into Lua, the string will have the 8 bytes as above--Lua doesn't decode that UTF-8 sequence to a Unicode code point. But our text drawing functions do, so you should get the expected result if you pass that string to e.g., gfx.drawText().

If it's not working that way for you can you post a small demonstration project that shows what the error is?

Thanks!

Here's a minimum reproduction: You need to make a file called test.txt with L“R” in the data folder for the game for it to work.
repro.zip (6.9 KB)

Even though the included font has the right glyphs it reads as null so can't display them:
image

Ah! There's the problem: It's still using the default font. :slight_smile: Do

f = playdate.graphics.font.new("Newsleak-Custom")
playdate.graphics.setFont(f)

in the setup and the quotes draw correctly.

Sorry for the bother! I really thought I had it set in my original program but it was commented out for some reason

1 Like