0

In C's <limits.h> or C++'s <climits> is defined a macro constant MB_LEN_MAX which is described as being:

maximum number of bytes in a multibyte character

The way I understand this is, is that it represents either the maximum size of a character (2 bytes in Java) or perhaps the biggest character literal you can make, eg. '\n' being 2 bytes and '\uFFFF' being 6 bytes.

Does anybody know what the "maximum number of bytes in a multibyte character" is in Java and if it is defined somewhere in the language specification?

  • If you don't know what it is (and that isn't obvious to me), what use would an equivalent be? / `char` is always the equivalent of two bytes though you shouldn't have to deal with that other than that they are in the range 0..65535, but code points can be larger. – Tom Hawtin - tackline Nov 11 '19 at 20:15
  • Not a duplicate, but some info about characters [here](https://stackoverflow.com/questions/5078314/isnt-the-size-of-character-in-java-2-bytes) – Federico klez Culloca Nov 11 '19 at 20:16
  • @TomHawtin-tackline Porting C code to Java and require that I have an equivalent of the `limits.h` file defined. –  Nov 11 '19 at 20:16
  • @TomHawtin-tackline Quite frankly I don't know if I'm after just the 2 bytes or the larger code points. :/ –  Nov 11 '19 at 20:19
  • @FedericoklezCulloca Thank you. One of the answers suggests it _might be_ a 4 byte maximum but I must search some more... –  Nov 11 '19 at 20:19
  • @FinnRayment It's probably worth looking at how it is actually used in the code that you are porting. – Tom Hawtin - tackline Nov 11 '19 at 21:28

0 Answers0