Exemplo n.º 1
0
 public string DecodeString(ByteString data)
 {
     if (options.OptimizeStrings)
     {
         return(ImprovedLowerCaseStringEncoder.DecodeBytes(data.ToByteArray()));
     }
     else
     {
         return(System.Text.Encoding.UTF8.GetString(data.ToByteArray()));
     }
 }
Exemplo n.º 2
0
 internal void WriteString(BinaryWriter writer, string data)
 {
     if (options.OptimizeStrings)
     {
         ImprovedLowerCaseStringEncoder.WriteString(writer, data);
     }
     else
     {
         var bytes = System.Text.Encoding.UTF8.GetBytes(data);
         writer.Write(bytes);
     }
 }
Exemplo n.º 3
0
 internal string ReadString(BinaryReader reader, int count)
 {
     if (options.OptimizeStrings)
     {
         return(ImprovedLowerCaseStringEncoder.ReadString(reader, count));
     }
     else
     {
         var bytes = reader.ReadBytes(count);
         return(System.Text.Encoding.UTF8.GetString(bytes));
     }
 }
Exemplo n.º 4
0
 public ByteString EncodeString(string data)
 {
     if (options.OptimizeStrings)
     {
         var bytes = ImprovedLowerCaseStringEncoder.EncodeString(data);
         return(ByteString.CopyFrom(bytes));
     }
     else
     {
         var bytes = System.Text.Encoding.UTF8.GetBytes(data);
         return(ByteString.CopyFrom(bytes));
     }
 }