public static String stringDefaultValue(String bytes){
  return new String(bytes.getBytes(ISO_8859_1),InternalNano.UTF_8);
}

public static String stringDefaultValue ( String bytes ) { return new String ( bytes . getBytes ( ISO_8859_1 ) , InternalNano . UTF_8 ) ; }
helper called by generated code to construct default values for string fields . < p > the protocol compiler does not actually contain a utf - 8 decoder - - it just pushes utf - 8 - encoded text around without touching it . the one place where this presents a problem is when generating java string literals . unicode characters in the string literal would normally need to be encoded using a unicode escape sequence , which would require decoding them . to get around this , protoc instead embeds the utf - 8 bytes into the generated code and leaves it to the runtime library to decode them . < p > it gets worse , though . if protoc just generated a byte array , like : new byte [ ] { 0x12 , 0x34 , 0x56 , 0x78 } java actually generates * code * which allocates an array and then fills in each value . this is much less efficient than just embedding the bytes directly into the bytecode . to get around this , we need another work - around . string literals are embedded directly , so protoc actually generates a string literal corresponding to the bytes . the easiest way to do this is to use the iso - 8859 - 1 character set , which corresponds to the first 256 characters of the unicode range . protoc can then use good old cescape to generate the string . < p > so we have a string literal which represents a set of bytes which represents another string . this function - - stringdefaultvalue - - converts from the generated string to the string we actually want . the generated code calls this automatically .
