HALFWIDTH != Half the width

by Michael S. Kaplan, published on 2007/05/01 21:59 -04:00, original URI: http://blogs.msdn.com/b/michkap/archive/2007/05/01/2366714.aspx


So what do you think is wrong with the following code?

WCHAR wz1[] = L"\uFF71"; // HALFWIDTH KATAKANA LETTER A
WCHAR wz2[] = L"\u30A2"; // KATAKANA LETTER A

// Make sure the half width characters have half the width
if(CompareStringW(LOCALE_USER_DEFAULT, wz1, 1, wz2, 2) == CSTR_EQUAL) {
    // They are equal!
}

(HINT: here

Obviously this code is bad because it is confusing the "width" of the characters in regard to their visual appearance and the size of the two buffers.

The moral of the story? HALFWIDTH and FULLWIDTH in Unicode are simply descriptive terms about the appearance of the characters; they have NOTHING to do with the size of buffers.

 

This post brought to you by(U+ff21, a.k.a. FULLWIDTH LATIN CAPITAL LETTER A)


no comments

Please consider a donation to keep this archive running, maintained and free of advertising.
Donate €20 or more to receive an offline copy of the whole archive including all images.

referenced by

2008/06/09 Did you lose some WIDTH or something?

go to newer or older post, or back to index or month or day