How to identified given string is double byte characterset using java?
I want to Identify given string开发者_高级运维 is double byte character set or not, using java?
Thanks
A String
does not have a character set property, in fact, it is always UTF-16 (16 bit used for each char).
If you wanted to try to discover the likely charset of some input data (e.g. in a file or stream), then the ICU4J CharsetDetector could be used.
But by the time the data is in a String in your code, it is too late.
Your string has multibyte characters if String.codePointCount(int beginIndex, int endIndex)
for the whole text range will give not zero result.
精彩评论