3

I just wonder whether 0xFFFF is a valid Unicode character.

When I using the following code:

CStringW strTempW;
CString strTemp1;
INT_PTR nLen;

strTempW.Format(L"%c", 0xFFFF);
nLen = strTempW.GetLength();

strTemp1 += strTempW;
nLen = strTemp1.GetLength();

After executing the first codeline strTempW.Format(L”%c”, 0xFFFF), I will get strTempW of length 1, but cannot see it first character in Visual Studio watch window.

After executing the codeline strTemp1 += strTempW, I will get strTemp1 of length 0.

That is confusing to me. Is 0xFFFF taken as a valid Unicode code point or not?

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
alancc
  • 487
  • 2
  • 24
  • 68

2 Answers2

13

Go to the Unicode web site unicode.org/charts and enter FFFF in the box. It will give you a PDF to download (UFFF0.pdf for this character code; different files for different codes).

You'll find that U+FFFF is not a valid Unicode character:

FFFF <not a character>

  • The value FFFF is guaranteed not to be a Unicode character at all
Community
  • 1
  • 1
Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
  • 1
    Moreover, *all* the last two bytes in each plane are excluded. – Kerrek SB Dec 23 '13 at 00:54
  • Thanks, @KerrekSB. That doesn't surprise me, but I'd not validated it. I knew that U+10FFFF, the largest value in Unicode, is not a character, but I didn't want to generalize without investigating (and I was too lazy to investigate at the moment). – Jonathan Leffler Dec 23 '13 at 00:59
4

As stated in this great answer it is not, it is a reserved non character.

Community
  • 1
  • 1
lwi
  • 1,682
  • 12
  • 21