Question on Unicode.Encoding.encodedReplacementCharacter

From "UnicodeEncoding.swift":

  /// A unicode scalar value to be used when repairing
  /// encoding/decoding errors, as represented in this encoding.
  /// If the Unicode replacement character U+FFFD is representable in this
  /// encoding, `encodedReplacementCharacter` encodes that scalar value.
  static var encodedReplacementCharacter : EncodedScalar { get }

So, what do you return if your type can't handle a U+FFFD value? And how do you warn clients of this? Do you just set an arbitrary random garbage value, then have the client check if it's actually U+FFFD?

IIRC, the existing ASCII encoding uses U+001A (substitute character), but beyond that I don't know.

Terms of Service

Privacy Policy

Cookie Policy