DrawText behaves differently on sim/device (C API)

When trying to display Japanese text in the C API, I noticed that I was getting completely different results on device/sim based on character encoding and whether or not I use strings/wide strings.

Test code:
code

Result on device:
device

Result on sim:
sim

1 Like

I saw your post on discord; you're on Windows right? What's the encoding of your source file? What compiler are you using?

Thanks for the reply. I'm on Windows 11, files are encoded in UTF-8 BOM (although I tried with no BOM as well). Using Visual Studio 2022.

Ran into this one today, same behavior as Nnnn

additional data point is that mac simulator shares the device behavior

Do all these strings render correctly on device? The way windows treats encoding is much different than the Mac so it's not surprising this doesn't work when embedding unicode characters directly into source files.

EDIT: After talking to another engineer and looking in to this issue I got different results than you are seeing (and my results matched the device):

  1. The PD API doesn't support wide strings, so L"" string will not work
  2. Works as expected, a UTF8 string using draw UTF8 encoding constant
  3. Wide string, won't work
  4. UTF8 encoded string being told to draw using UTF16 encoding, won't work

How did you type these strings into the editor? Are they UTF16 and not UTF8? I'm using VS Code with UTF8 file encoding.

Thanks for the reply, and sorry for forgetting about this thread for a year.
Went back to an old project, and remembered that this is why I dropped it. Checked and unfortunately am still getting the same/similar behavior. It looks like none of the methods work correctly for the simulator atm, since some characters I was able to display before (katakana) don't get output anymore.

I am using Visual Studio 2022, source files with UTF8 encoding. I'm not sure what you mean by how I typed them into the editor, since I just typed them normally. I did try a bunch of variants of unicode/jis/etc formattings just for the hell of it, and all of them gave different results, but I wasn't able to correctly output japanese text with any of them (but it does confirm my encodings are getting changed/saved).

No, not all of them render correctly on device. On device, only the proper method (#2) renders correctly. You can see a screenshot of the output in OP.