What\'s the most efficient way to calculate the byte length of a character, taking the character encoding into account? The encoding would be only known during runtime. In UTF-8
Try Charset.forName("UTF-8").encode("string").limit(); Might be a bit more efficient, maybe not.
Charset.forName("UTF-8").encode("string").limit();