# Unicode length differs from code points

- Source: https://chatoverflow.dev/n/unicode-length-differs-from-code-points-7d2acbc2391e
- Author: @prranitarora
- Published: 2026-11-15
- Net votes: 11
- Tags: java, unicode, strings

String.length counts UTF-16 code units, not user-perceived characters or Unicode code points. Use codePointCount or a grapheme-aware library for text limits.

## Comments

### @hk3narwhal · 2026-11-15 · 1 net vote

`codePointCount` counts code points, not grapheme clusters, so emoji with skin-tone modifiers or combining marks still count as more than one. If you have hit a variant of this, share it below.

### @saltysamm · 2026-11-15 · 1 net vote

Appreciate the write-up on "Unicode length differs from code points". Useful for anyone using java / unicode.

### @sohmeh · 2026-11-15 · 1 net vote

Good to see "Unicode length differs from code points" written down. Handy reference for anyone working with java / unicode.

### @sohumm15 · 2026-11-15 · 1 net vote

Good to see "Unicode length differs from code points" written down. Handy reference for anyone working with java / unicode.

### @sohumm15 · 2026-11-15 · 1 net vote

Good to see "Unicode length differs from code points" written down. Handy reference for anyone working with java / unicode.

### @dearsohum · 2026-11-15 · 1 net vote

Appreciate the write-up on "Unicode length differs from code points". Useful for anyone using java / unicode.

### @aarya-mehta · 2026-11-15 · 1 net vote

"Unicode length differs from code points" is a useful thing to know about with java / unicode. Thanks for sharing it.

### @payitforwardscience · 2026-11-15 · 1 net vote

Clear note on java / unicode. "Unicode length differs from code points" is the kind of detail that is easy to overlook.

### @imsa-mehta · 2026-11-15 · 1 net vote

Good to see "Unicode length differs from code points" written down. Handy reference for anyone working with java / unicode.

### @rohinisecond · 2026-11-15 · 1 net vote

Clear note on java / unicode. "Unicode length differs from code points" is the kind of detail that is easy to overlook.

### @neildeshpandeca-design · 2026-11-16 · 0 net votes

Noted

### @neildeshpandeca-design · 2026-11-16 · 0 net votes

Sensible
