Click here to Skip to main content
16,016,425 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
PinnedHOW TO ANSWER A QUESTION PinPopular
Chris Maunder12-Jul-09 22:37
cofounderChris Maunder12-Jul-09 22:37 
PinnedHOW TO ASK A QUESTION PinPopular
Chris Maunder12-Feb-09 17:19
cofounderChris Maunder12-Feb-09 17:19 
Questionbuild4ARM Pin
wa!724-Sep-24 18:05
wa!724-Sep-24 18:05 
QuestionRe: build4ARM Pin
CPallini24-Sep-24 19:52
mveCPallini24-Sep-24 19:52 
AnswerRe: build4ARM Pin
wa!725-Sep-24 4:08
wa!725-Sep-24 4:08 
QuestionReading HID Bluetooth devices' buffer on Win32 Pin
GIANISM_JUSTICE22-Sep-24 4:04
GIANISM_JUSTICE22-Sep-24 4:04 
QuestionGUI Freezes randomly /MFC /C++ Pin
Zishan Ud78720-Sep-24 8:56
Zishan Ud78720-Sep-24 8:56 
AnswerRe: GUI Freezes randomly /MFC /C++ Pin
Richard Andrew x6420-Sep-24 10:07
professionalRichard Andrew x6420-Sep-24 10:07 
GeneralRe: GUI Freezes randomly /MFC /C++ Pin
jeron120-Sep-24 10:47
jeron120-Sep-24 10:47 
GeneralRe: GUI Freezes randomly /MFC /C++ Pin
Zishan Ud78720-Sep-24 23:11
Zishan Ud78720-Sep-24 23:11 
GeneralRe: GUI Freezes randomly /MFC /C++ Pin
Zishan Ud78720-Sep-24 23:16
Zishan Ud78720-Sep-24 23:16 
AnswerRe: GUI Freezes randomly /MFC /C++ Pin
Dave Kreskowiak20-Sep-24 13:53
mveDave Kreskowiak20-Sep-24 13:53 
QuestionRe: GUI Freezes randomly /MFC /C++ Pin
David Crow23-Sep-24 2:05
David Crow23-Sep-24 2:05 
QuestionCharacter set Pin
Calin Negru12-Sep-24 23:03
Calin Negru12-Sep-24 23:03 
AnswerRe: Character set Pin
CPallini12-Sep-24 23:19
mveCPallini12-Sep-24 23:19 
GeneralRe: Character set Pin
Calin Negru12-Sep-24 23:46
Calin Negru12-Sep-24 23:46 
GeneralRe: Character set Pin
Mircea Neacsu13-Sep-24 0:06
Mircea Neacsu13-Sep-24 0:06 
GeneralRe: Character set Pin
trønderen13-Sep-24 9:33
trønderen13-Sep-24 9:33 
Mircea Neacsu wrote:
the most popular by far being UTF-8[^].
I'd say that the most popular file storage format is UTF-8.

As a working format, in RAM, UTF-16 is very common. E.g. it is the format used by all Windows APIs, which is more or less to say all Windows programs. Java uses UTF-16 in RAM, as do a lot of other modern languages.

It must be said that not all software that claims to use UTF-16 fully handles UTF-16 - only the BMP ("Basic Multilingual Plane"), so that all supported characters will fit in one 16-bit code unit. BMP didn't have space for latecomer alphabets, like for a number of African or Asian languages. Most developers said "But my program isn't aimed at such markets, so I'll ignore the UTF-16 surrogates, for handling such characters as two 16-bit code units. I can treat text as if all characters are of equal width, 16 bits".

But a new situation has arisen: Emojis have procreated to a number far exceeding the number of WinDings. They do not all fit in BMP, so a number of them have been allocated in other planes than BMP. Don't expect the end user to know which emojis are defined in which planes and refrain from using non-BMP emojis! If you are not prepared for them, your code may mess up the text badly.

Writing your own complete UTF-16 interpreter is not recommended. Use library functions! There is more to UTF-16 than just alternative planes: Some character codes are nonspacing, or combining (typically an accent and a character). So you cannot deduce the number of print positions from the length of the UTF-16 string - not even after considering control characters.

For "trivial" strings limited to Western alphabets, there usually is a fairly close correspondence between the number of UTF-16 code units and the number of positions. You can pretend that it is exact, but look out for cases that need to be treated as exceptions. I suspect that is what a lot of programmers do. 99,9% of Western text is free of exceptional cases, so the fixed-code-width assumption holds. Until, of course, emojis become common e.g. in file names. Note that UTF-32 does not provide an ultimate solution to all problems: You still may have to relate to nonspacing or combining characters!
Religious freedom is the freedom to say that two plus two make five.

GeneralRe: Character set Pin
Mircea Neacsu13-Sep-24 17:17
Mircea Neacsu13-Sep-24 17:17 
GeneralRe: Character set Pin
trønderen14-Sep-24 7:25
trønderen14-Sep-24 7:25 
GeneralRe: Character set Pin
Mircea Neacsu14-Sep-24 15:10
Mircea Neacsu14-Sep-24 15:10 
GeneralRe: Character set Pin
trønderen14-Sep-24 17:27
trønderen14-Sep-24 17:27 
GeneralRe: Character set Pin
Mircea Neacsu15-Sep-24 2:26
Mircea Neacsu15-Sep-24 2:26 
GeneralRe: Character set Pin
trønderen15-Sep-24 12:16
trønderen15-Sep-24 12:16 
GeneralRe: Character set Pin
Richard MacCutchan15-Sep-24 21:08
mveRichard MacCutchan15-Sep-24 21:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.