If the PKI_X509_UTF8 flag is specified in nOptions,
all new DN attribute strings will be encoded as UTF8String
.
If the UTF-8 flag is set and the value contains only valid UTF-8-encoded characters, then the string will be copied directly. Otherwise the input is assumed to be 8-bit Latin-1 and will be converted to UTF-8 accordingly, with each 8-bit character being converted to two UTF-8 bytes.
Input string | Default encoding | With PKI_X509_UTF8 |
---|---|---|
OU=abc | PrintableString "abc" | UTF8String "abc" |
OU=#x616263 | PrintableString "abc" | UTF8String "abc" |
OU='a\62c' | PrintableString "abc" | UTF8String "abc" |
C=M\e9xico | T61String "México" | UTF8String "México" |
C=#x4de97869636f | T61String "México" | UTF8String "México" |
C=#x4dc3a97869636f | T61String (garbage!) | UTF8String "México" |
CN=#xE5A4A7E58DAB | T61String (garbage!) | UTF8String (U+5927,U+536B) |
CN='\E5\A4\A7\E5\8D\AB' | T61String (garbage!) | UTF8String (U+5927,U+536B) |
The last two examples give the same result as two CJK ideographs, U+5927 (da) and U+536B (wei), encoded in UTF-8.
See the second example in X509_MakeCertSelf
.