Answer the question
In order to leave comments, you need to log in
How to convert hex utf-8 to utf-16?
There is a number 127997.
HEX of this number (result of php function dechex('127997')) = 1f3fd.
I also know the values of this number in UTF-16 encoding:
UTF-16 (hex) 0xD83C 0xDFFD (d83cdffd)
UTF-16 (decimal) 55 356 57 341
So I can’t find a function (or function algorithm) in php that would allow to get from 127997 its value in UTF-16 encoding. Any - either hex (d83cdffd) or decimal (55 356 57 341).
Can anyone come across?
Answer the question
In order to leave comments, you need to log in
127997 is UTF-32.
Look for UTF-32 -> UTF-16
www.fileformat.info/info/unicode/char/1f3fd/index.htm
Coding principle
The symbol code is arithmetically shifted to zero (the minimum number 10000 is subtracted from it). The result is a value from zero to FFFFF, which takes up to 20 bits.
The upper 10 bits (a number in the range 0000..03FF) are summed with D800, and the result goes into the leading (first) word, which is in the range D800..DBFF.
The lower 10 bits (also a number in the range 0000..03FF) are summed with DC00, and the result goes into the next (second) word, which is included in the range DC00..DFFF.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question