Documentation issue in juce::String

juce::String:: copyToUTF8’s documentation says:

To find out how many bytes you need to store this string as UTF-8, you can call CharPointer_UTF8::getBytesRequiredFor (myString.getCharPointer())

(and same phrase appears for other methods as well)

Wouldn’t using String::getNumBytesAsUTF8() be more convenient?? Am I missing something here? If I’m not then perhaps the documentation should suggest this method.

2 Likes

Bump (after spending too many time to find howto :thinking:).

String::getNumBytesAsUTF8 is implemented using CharPointer_UTF8::getBytesRequiredFor, so in the case of UTF8 these two techniques should be interchangeable.

String doesn’t have a getNumBytesAsUTF16 or getNumBytesAsUTF32, so using a CharPointer is the only way to get the bytes required for these encodings.

1 Like