1
0
Fork
You've already forked mojibake
0
Mojibake is V library JIS X 0213:2004 ↔ UTF-8 text encoding conversion
  • V 100%
2023年01月24日 18:52:41 +03:00
.editorconfig Mojibake v1.0.0 2023年01月22日 10:03:54 +03:00
.gitattributes Mojibake v1.0.0 2023年01月22日 10:03:54 +03:00
.gitignore Mojibake v1.0.0 2023年01月22日 10:03:54 +03:00
jis_x_0213_to_utf8_data.v Mojibake v1.1.0 2023年01月22日 22:28:36 +03:00
LICENSE.md Mojibake v1.0.0 2023年01月22日 10:03:54 +03:00
mojibake.v Mojibake v1.2.0 2023年01月24日 18:47:51 +03:00
README.md README fix 2023年01月24日 18:52:41 +03:00
utf8_to_jis_x_0213_data.v Mojibake v1.2.0 2023年01月24日 18:47:51 +03:00
v.mod Mojibake v1.2.0 2023年01月24日 18:47:51 +03:00

Mojibake

Mojibake (Japanese: 文字化け; IPA: [mod͡ʑibake], "character transformation") is the garbled text that is the result of text being decoded using an unintended character encoding.

Mojibake is V library JIS X 0213:2004 ↔ UTF-8 text encoding conversion

License

LGPL-3.0-or-later

  1. Main repo
  2. GitHub mirror
  3. Project X0213

Example

import mojibake
fn main() {
	println(mojibake.jis_x_0213_to_utf8([u8(0x82), 0x94, 0x82, 0x94, 0x82, 0x8c, 0x2e, 0x58, 0x4d, 0x4c, 0x00]))
	// 'ttl.XML'
}

Credits

Project X0213 for code mapping tables

Caution

mojibake\jis_x_0213_*byte*.v were semi-autogenerated from this file and this one-liner:

cat sjis-0213-2004-with-char-u8.txt | tail --lines=+26 | grep -Pv '<reserved>|<doublebytes>|<control>' | awk -F '\t' '{print 2ドル": [`"3ドル"`].string() // "3ドル" "4ドル}' | awk '{sub(/\[`\\u\w\w\w\w\w`\].string\(\)/, "utf32_to_str("4ドル")", 2ドル); print 0ドル}' | awk '{sub(/\(U\+/, "(0x", 2ドル); print 0ドル}'