gaob13 / kryo

Automatically exported from code.google.com/p/kryo
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Add [Output.writeUnicode(String value)] #85

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
[Output.writeUnicode] must be exposed the same way you exposed 
[Output.writeAscii]

Very often user knows that it's using Unicode chars in strings.
so the following code in [Ouput.writeString] is small but overkill:

// Detect ASCII.
boolean ascii = false;
if (charCount > 1 && charCount < 64) {
    ascii = true;
    for (int i = 0; i < charCount; i++) {
        int c = value.charAt(i);
        if (c > 127) {
            ascii = false;
            break;
        }
    }
}

Original issue reported on code.google.com by denysenk...@gmail.com on 23 Aug 2012 at 5:55

GoogleCodeExporter commented 8 years ago
It can be done in one line using current code:

public void writeUnicode (String value) throws KryoException {
    writeString((CharSequence)value);
}

Original comment by denysenk...@gmail.com on 23 Aug 2012 at 6:06