You could call getBytes(CharSet).length on the string to find out how many bytes it represents. That is usually how many characters it would take in a DB.
In Java, Length of a String with Mix of Chinese and English in Varchar
-
01-06-2022 - |
Frage
Sorry I know the title of this question doesn't make any sense.
The problem is that I have database column is 100 varchar in size. I want to insert value with mix of Chinese and English in 1 String, I need to check the length of the String in my java code in case I need to truncate it. Since 1 Chinese char takes 3 varchars, is there an easy way I can find out how many varchars is needed in my String?
Thanks,
Lösung
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow