Skip to content
Tcl Source Code View Ticket
Login

View Ticket

Add GB18030 encoding

Open367bfdcf896f8cf47f369a0a054b9a9afeec94b0Created 6 years agoUpdated 6 years ago
Descriptionwiki2020-11-18 11:05:43
Encoding GB18030 (Chines national standard 18030) is an encoding which is required for any software in China. This gives a certain preasure to support it.

It is challenging, as the whole Unicode range is covered, but ordered in a different way.

It is compatible to already present encoding GB2312 in a way, that GB2312 codepoints still apply.

Jan Nijtmans wrote about the technical details in ticket [9575f0dec8]:

Well, how about TIP #389 then? In Tcl 8.7 we can use characters > U+FFFF by storing them as surrogate pairs. So a single (multibyte) character could result in 2 surrogates. That's not possible now, with the current "*.enc" files.

Currently there are 4 types of "*.enc" files: Single-byte ("S"), double-byte("D") escape-driven("E") and multi-byte("M"). So, we would need a 5th type (e.g. "U"), I don't see why that wouldn't be possible.

For Tcl 9, we have 32-bit characters, but still we would need the same additional format: we cannot do it with the existing "*.enc" files.

Referenced by1
  • 45b435b284Ticket [cef426ff2c] Encoding UTF-32 missing status still Open with 4 other changes ticket2021-10-13 11:30:14
jan.nijtmanswiki2020-11-19 13:19:18

A lot simpler implementation would be to use MultiByteToWideChar/WideCharToMultiByte on Windows (codepage 54936) and iconv on other systems.

oehharwiki2020-11-19 13:40:37

So we could remove the whole encoding machinery and let the operating system do the job? That is great. The starkit file size will shring by a magnitude. So we could also address the IMHO open points:

  • Return positions with not encodable points
  • Return information on incomplete multibyte characters (specially at the end of the string) or invalid characters
  • Return encoding errors

Thank you, Harald

Log in (anonymous is fine) to add a comment.