title: Convert unicode codepoint to utf-16
body: <p>In C++ on Windows how do you convert an xml character reference of the form <code>&amp;#xhhhh;</code> to a utf-16 little endian string?</p>
  <p>I'm thinking if the hhhh part is 4 characters or less, then it's 2 bytes, which fit into one utf-16 character. But, this <a href="https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references" rel="nofollow noreferrer">wiki page has a table of character references</a> and some near the bottom are 5 digit hex numbers which won't fit into two bytes. How can they be converted to utf-16?</p>
  <p>I'm wondering if the <a href="https://docs.microsoft.com/en-us/windows/win32/api/stringapiset/nf-stringapiset-multibytetowidechar" rel="nofollow noreferrer">MultiByteToWideChar</a> function is capable of doing the job.</p>
  <p>My understanding of how a code point that's bigger than 2 bytes gets converted to utf-16 is lacking! (Or for that matter I'm not too sure how a code point that's bigger than 1 byte get's converted to utf-8, but that's another question).</p>
  <p>Thanks.</p>