KCC(1)

πŸ“¦
version 2.3+really Β· 2 versions
, in debian bookworm, ubuntu jammy, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– KCC(1) πŸ’–

okay bestie, sit down, hydrate, because we are talking about kcc today and she is that girl. she lives in the General Commands Manual section of your man pages, and honestly? she earned it. πŸ‘‘


✨ NAME ✨

kcc β€” kanji code coverter with encoding auto detection

not me pointing out that the original literally spells it "coverter" πŸ’€ we love her, she's iconic, we're keeping it exactly as she is, no notes.

🌸 SYNOPSIS 🌸

kcc [ -IOchnvxz ] [ -b bufsize ] [ file ] ...

πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the vibe: kcc is a filter. it reads a file sequentially, converts kanji encodings, and outputs everything to stdout. that's the whole job. main character behaviour, honestly. πŸ’…

if you don't hand it any file β€” or if you literally pass - as the filename β€” it reads from stdin instead. piping queen. 🫢

you can specify the kanji encodings for input and output yourself, but here's the slay: kcc detects the input encoding automatically if you don't specify an input encoding. no cap, she just knows. ✨

the kanji encodings available to you are JIS (7 bit and/or 8 bit), Shift JIS, EUC, and DEC. 🌈

for input encoding, you're allowed to mix them when they're a pair of one of EUC, DEC or Shift JIS and 7 bit JIS. and SI/SO, ESC(I are recognized as halfwidth of JIS.


πŸŽ€ OPTIONS πŸŽ€

  • -O β€” yep, that's it, that's the option. she stands alone, she's mysterious, she's lowkey giving nothing and everything at the same time. πŸ™ˆ
  • -IO β€” I is for input kanji encoding, O is for output kanji encoding. When no input encoding is specified, it gets detected automatically, and if both input and output aren't specified, the output encoding is 7 bit JIS.

For the input encoding option, I, you can specify one of the followings:

  • e β€” EUC (available with 7 bit JIS)
  • d β€” DEC (available with 7 bit JIS)
  • s β€” Shift JIS (available with 7 bit JIS)
  • j7 or k β€” 7 bit JIS
  • 8 β€” 8 bit JIS

For the output encoding option, O, you can specify one of the followings:

  • e β€” EUC
  • d β€” DEC
  • s β€” Shift JIS
  • jXY or 7XY β€” 7 bit JIS (using SI/SO for JIS kana designation)
  • kXY β€” 7 bit JIS (using ESC(I for JIS kana designation)
  • 8XY β€” 8 bit JIS

by XY in the O option, you get to specify which escape sequence is used in JIS encoding. BJ is the default. Supplimental kanji designation is fixed to ESC$(D. periodt.

  • X β€” Kanji is designated by:
    • B β€” ESC$B (JIS X0208-1983)
    • @ β€” ESC$@ (JIS X0208-1978)
    • + β€” ESC&@ESC$B (JIS X0212-1990)
  • Y β€” Alpha Numerical is designated by:
    • B β€” ESC(B (ASCII)
    • J β€” ESC(J (JIS Roman; JIS X0201)
    • H β€” ESC(H (Swedish; strongly deprecated β€” bestie do NOT)
  • -v β€” outputs the result of input encoding detection to stderr. she's telling you what she thinks, out loud, to a different stream. πŸ’¬
  • -x β€” Extension mode. By auto detection of input encodings, recognize user-defined characters and extended character region (out of range of EUC, undefined halfwidth kana, control character, C1 area and/or extended character region Shift C1 JIS). Distinguishing between DEC and EUC is done in this mode.
  • -z β€” Shrink mode. Don't recognize halfwidth kana (except 7 bit JIS) with input encoding detection. With this option, accuracy of auto detection of input encodings becomes much better for files without halfwidth kana. glow up. ✨
  • -h β€” Normally, when converted halfwidth kana to DEC, it becomes fullwidth Katakana. With this option, it becomes Hiragana. cute lil switch. πŸŽ€
  • -n β€” user-defined characters, extended characters and supplimental kanji characters are converted to fullwidth white box, and undefined region of halfwidth kana are converted to halfwidth centered dot. she's giving placeholder energy. ⬜
  • -b bufsize β€” specify buffer size. 8kbytes is default.
  • -c β€” don't convert but check input encoding and print result to stdout. Different with normal auto-detection, the whole contents of file is checked. However, when inconsistency of encodings is found, it aborts reading and prints "data". Options except -x, -z are ignored. she said "i'm just looking, i'm not touching anything." πŸ‘€

πŸ”₯ EXAMPLES πŸ”₯

% kcc -e file

Input encoding are detect automatically, and output is in EUC encoding. effortless. πŸ’…

% kcc -sj file1 file2

Two files in Shift JIS concatinated with converting to JIS. two for one, we love a bundle deal. 🫢

% command | kcc -k+J

output of command are converted to JIS (JIS JIS X0208 JIS JIS Roman, ESC(I Halfwidth Kana JIS). the pipe goes crazy. 🌈

% kcc -c file

Encoding of contents of file is detected (no conversion). just peeking, no touch. πŸ‘‘


πŸ’€ BUG πŸ’€

Auto detection of input encoding is well done for normal case, however, it has the following problems. and bestie, we're gonna be honest about all of them because that's what besties do. 🫢

7 bit JIS is recognized by escape sequence in certain. EUC and DEC are the same (referred as EUC series). Halfwidth kana of 8 bit JIS is the same as halfwidth kana of Shift JIS (referred as Shift JIS series). However, EUC series and JIS, which are both 8 bit encoding, are sharing the same regions widely. So, the problem in auto detection is detection of these 2 encodings. it's giving "two queens sharing one dressing room." 😭

Detection of EUC series / Shift JIS series is done line by line. When it is found that it's not Shift JIS series, or it's not EUC series, the encoding is determined. When inconsistensy is found, it will be treated as "data" and the contents of output is not guaranteed. πŸ’€

While determined between EUC series / Shift JIS series after 8 bit code is found, conversions are pending and put input data in buffer, however, when the buffer is fulled, it assumes it's EUC series and forces to start conversion. Rationale: usually, we can assume that documents with kanji include JIS non-kanji or JIS first standard, it can be detected in certain if it is Shift JIS, which does not share region with EUC. So if it can't be determined, it's very likely to be EUC. logic? she has it. πŸ’…

8 bit JIS and it has always even number of halfwidth kana sequences, then it will be wrongly detected as EUC kanji. Be ceraful. 🚨

If input encoding doesn't have halfwidth kana, use -z and the accuracy of detection becomes much better. This is because shared region are restricted to area of JIS second standards. ✨

Extended region of Shift JIS, user-defined area of EUC, control characters C1 of EUC, undefined region of halfwidth kana of EUC are out of range of auto detection, so it will fails to detect encodings if input has these characters. Use -x option to specify extended mode, or specify input code. πŸ”§


🐱 SEE ALSO 🐱


🧚 NOTES 🧚

Usually, user-defined characters, extended characters, supplimental kanji characters are mapped respectively. However, characters that is out of range of extended characters become FCFC in hexadecimal when converted to Shift JIS. Although control character region C1 of EUC and DEC remains when converted to JIS, these will be deleted when converted to Shift JIS. Undefined area of halfwidth kana become halfwidth centered dot when convered to Shift JIS. Halfwidth kana become fullwidth kana when converted to DEC. πŸŒ€

When output is JIS encoding, control characters such as newline, TAB, DEL and white space (halfwidth) will be output in ASCII mode.

When encoding of input is detected wrongly, or input undefined character for expected character sets, output is indefined. undefined. not defined. bestie, guard your data. 😭

This manual are translated by Fumitoshi UKAI <ukai@debian.or.jp> for Debian system, but you can use it for any purpose. so generous, so giving, so iconic. πŸ’–


and that's the whole page, bestie!! this one was written by Y. Tonooka, dated November 19, 1992, and it's filed under KCC(1) in your friendly neighbourhood manual. mwah. πŸ’…βœ¨

πŸ“¦ where this page comes from