C++ UTF-8 output with ICU

后端 未结 3 1240
北恋
北恋 2021-01-11 11:57

I\'m struggling to get started with the C++ ICU library. I have tried to get the simplest example to work, but even that has failed. I would just like to output a UTF-8 stri

3条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-11 12:42

    What happens if you write the output to a file (either redirecting using pipes from the terminal, or by opening a file stream in the program itself)

    That would determine whether or not it is the terminal that fails to handle the output correctly.

    What happens if you inspect the output string in the debugger? Does it contain the correct values? Find out what the UTF-8 encoding of your string should look like, and compare it against what you get in the debugger. Or print out the integral value of each byte, and verify that those are correct.

    When working with encoding it is always tricky (but essential) to determine whether the problem lies in your program itself or in the conversion that happens when the text is output to the system. Take the terminal out of the equation and verify that your program generates the correct output.

提交回复
热议问题