How many bytes does it take to encode the JSON string "STR\uD834\uDD1E" in UTF-8, in UTF-16 and how many in UTF-32?

Member Avatar for LastMitch

How many bytes does it take to encode the JSON string "STR\uD834\uDD1E" in UTF-8, in UTF-16 and how many in UTF-32?

@kresimir

You need an array to contain the JSON string then you can convert the number of bytes.

This is in java:

String JSON = "JSON string";
byte[] b = JSON.getBytes("UTF-8");

or

String JSON = "JSON string";
byte[] b = JSON.getBytes("UTF-16");
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.