문제

While reading the source code of SortableIntField, I noticed that this class avoids "UCS-16 surrogates" when converting an integer to a String (see method int int2sortableStr(int, char[], int) of NumberUtils.java).

What issue would these characters raise?

도움이 되었습니까?

해결책

The comments of the given code are confusing, actually there is a mistake, Wikipedia:

Occasionally, articles about Unicode will mistakenly refer to UCS-2 as "UCS-16". UCS-16 does not exist; the authors who make this error usually intend to refer to UCS-2 or to UTF-16.

Your question #1: Why does SortableIntField avoid UCS-16 surrogates? To decrease running time and to save space by avoiding endiness, for instance.

Your question #2: What issue would these characters raise? Again, they would take more space and if the endiness is an issue, then also the running time would increase. And also remember to catch your exceptions, since otherwise you can put easily your server down.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top