Search code examples
stringthrift

Thrift string type encoding


Thrift strings are said to be encoding agnostic / binary strings. What exactly does this mean? Does Thrift use its own encoding in between processing by programming languages?

What's a binary string?

I understand ASCII char arrays (= strings in C-based languages), and Unicode byte sequences, but I'm not quite sure how to interpret "encoding agnostic or binary strings" in the context of Thrift.


Solution

  • Short answer: Strings are typically written as UTF-8 strings.

    Typically, since any Transport could change this behaviour. So it would be possible to write a Thrift transport that serializes strings in a different way.

    I'm not sure what Diwaker had in mind when he coined the term "binary string", but I'd guess this refers to the Thrift binary data type which is implemented most of the time as byte[] or the particular language's equivalent of it, but in some rare cases as a sequence of chars instead.