uni2ascii(1)

πŸ“¦
version 4.20 Β· 2 versions
, in debian trixie, nixos 26.05, nixpkgs unstable, ubuntu questing, ubuntu resolute, ubuntu stonking

🌈 uni2ascii 🌈

✨ NAME ✨

uni2ascii β€” the girl who takes your UTF-8 Unicode and converts it into a whole menu of 7-bit ASCII representations. no cap, she's fluent in like thirty flavors of escape sequence πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

uni2ascii [options] (<input file name>)

πŸ’– DESCRIPTION πŸ’–

okay so listen bestie, uni2ascii converts UTF-8 Unicode to various 7-bit ASCII representations. if you don't specify a format, she just defaults to standard hexadecimal format (e.g. 0x00e9) because that's her comfort zone. she reads from the standard input and writes to the standard output, like a well-behaved icon. periodt.

Command line options are:

πŸ‘‘ OPTIONS πŸ‘‘

  • -A β€” List the single character approximations carried out by the -y flag. she'll show you the whole receipts, no secrets 🧾
  • -a <format> β€” Convert to the specified format. and here's the tea: you can name a format by these arbitrary single character codes, by names like "SGML_decimal", or literally just by showing her an example of the format you want. she'll figure it out. main character energy fr fr πŸ’«
    • A β€” Generate hexadecimal numbers with prefix U in angle-brackets (e.g. <U00E9>).
    • B β€” Generate \x-escaped hex (e.g. \x00E9)
    • C β€” Generate \x escaped hexadecimal numbers in braces (e.g. \x{00E9}).
    • D β€” Generate decimal HTML numeric character references (e.g. &#0233;)
    • E β€” Generate hexadecimal with prefix U (U00E9).
    • F β€” Generate hexadecimal with prefix u (u00E9).
    • G β€” Convert hexadecimal in single quotes with prefix X (e.g. X'00E9').
    • H β€” Generate hexadecimal HTML numeric character references (e.g. &#x00E9;)
    • I β€” Generate hexadecimal UTF-8 with each byte's hex preceded by an =-sign (e.g. =C3=A9) . This is the Quoted Printable format defined by RFC 2045.
    • J β€” Generate hexadecimal UTF-8 with each byte's hex preceded by a %-sign (e.g. %C3%A9). This is the URI escape format defined by RFC 2396.
    • K β€” Generate octal UTF-8 with each byte escaped by a backslash (e.g. \303\251)
    • L β€” Generate \U-escaped hex outside the BMP, \u-escaped hex within the BMP (U+0000-U+FFFF).
    • M β€” Generate hexadecimal SGML numeric character references (e.g. \#xE9;)
    • N β€” Generate decimal SGML numeric character references (e.g. \#233;)
    • O β€” Generate octal escapes for the three low bytes in big-endian order (e.g. \000\000\351))
    • P β€” Generate hexadecimal numbers with prefix U+ (e.g. U+00E9)
    • Q β€” Generate character entities (e.g. &eacute;) where possible, otherwise hexadecimal numeric character references.
    • R β€” Generate raw hexadecimal numbers (e.g. 00E9)
    • S β€” Generate hexadecimal escapes for the three low bytes in big-endian order (e.g. \x00\x00\xE9)
    • T β€” Generate decimal escapes for the three low bytes in big-endian order (e.g. \d000\d000\d233)
    • U β€” Generate \u-escaped hexadecimal numbers (e.g. \u00E9).
    • V β€” Generate \u-escaped decimal numbers (e.g. \u00233).
    • X β€” Generate standard hexadecimal numbers (e.g. 0x00E9).
    • 0 β€” Generate hexadecimal UTF-8 with each byte's hex enclosed within angle brackets (e.g. <C3><A9>).
    • 1 β€” Generate Common Lisp format hexadecimal numbers (e.g. #x00E9).
    • 2 β€” Generate Perl format decimal numbers with prefix v (e.g. v233).
    • 3 β€” Generate hexadecimal numbers with prefix $ (e.g. $00E9).
    • 4 β€” Generate Postscript format hexadecimal numbers with prefix 16# (e.g. 16#00E9).
    • 5 β€” Generate Common Lisp format hexadecimal numbers with prefix #16r (e.g. #16r00E9).
    • 6 β€” Generate ADA format hexadecimal numbers with prefix 16# and suffix # (e.g. 16#00E9#).
    • 7 β€” Generate Apache log format hexadecimal UTF-8 with each byte's hex preceded by a backslash-x (e.g. \xC3\xA9).
    • 8 β€” Generate Microsoft OOXML format hexadecimal numbers with prefix _x and suffix _ (e.g. _x00E9_).
    • 9 β€” Generate %\u-escaped hexadecimal numbers (e.g. %\u00E9).
  • -B β€” Transform to ASCII if possible. This option is equivalent to the combination cdefx. it's the "just make it work" button, lowkey iconic 🫢
  • -c β€” Convert circled and parenthesized characters to their unenclosed counterparts. freedom!! let them OUT of the circle β­•βž‘οΈβœ¨
  • -d β€” Strip diacritics. This converts single codepoints representing characters with diacritics to the corresponding ASCII character and deletes separately encoded diacritics. bye bye little accent marks, you served πŸ’¨
  • -e β€” Convert characters to their approximate ASCII equivalents, as follows:
    • U+0085 next line β†’ 0x0A newline
    • U+00A0 no break space β†’ 0x20 space
    • U+00AB left-pointing double angle quotation mark β†’ 0x22 double quote
    • U+00AD soft hyphen β†’ 0x2D minus
    • U+00AF macron β†’ 0x2D minus
    • U+00B7 middle dot β†’ 0x2E period
    • U+00BB right-pointing double angle quotation mark β†’ 0x22 double quote
    • U+1361 ethiopic word space β†’ 0x20 space
    • U+1680 ogham space β†’ 0x20 space
    • U+2000 en quad β†’ 0x20 space
    • U+2001 em quad β†’ 0x20 space
    • U+2002 en space β†’ 0x20 space
    • U+2003 em space β†’ 0x20 space
    • U+2004 three-per-em space β†’ 0x20 space
    • U+2005 four-per-em space β†’ 0x20 space
    • U+2006 six-per-em space β†’ 0x20 space
    • U+2007 figure space β†’ 0x20 space
    • U+2008 punctuation space β†’ 0x20 space
    • U+2009 thin space β†’ 0x20 space
    • U+200A hair space β†’ 0x20 space
    • U+200B zero-width space β†’ 0x20 space
    • U+2010 hyphen β†’ 0x2D minus
    • U+2011 non-breaking hyphen β†’ 0x2D minus
    • U+2012 figure dash β†’ 0x2D minus
    • U+2013 en dash β†’ 0x2D minus
    • U+2014 em dash β†’ 0x2D minus
    • U+2018 left single quotation mark β†’ 0x60 left single quote
    • U+2019 right single quotation mark β†’ 0x27 right or neutral single quote
    • U+201A single low-9 quotation mark β†’ 0x60 left single quote
    • U+201B single high-reversed-9 quotation mark β†’ 0x60 left single quote
    • U+201C left double quotation mark β†’ 0x22 double quote
    • U+201D right double quotation mark β†’ 0x22 double quote
    • U+201E double low-9 quotation mark β†’ 0x22 double quote
    • U+201F double high-reversed-9 quotation mark β†’ 0x22 double quote
    • U+2022 bullet β†’ 0x6F small letter o
    • U+2028 line separator β†’ 0x0A newline
    • U+2032 prime β†’ 0x27 right or neutral single quote
    • U+2033 double prime β†’ 0x22 double quote
    • U+2039 single left-pointing angle quotation mark β†’ 0x60 left single quote
    • U+203A single right-pointing angle quotation mark β†’ 0x27 right or neutral single quote
    • U+204E low asterisk β†’ 0x2A asterisk
    • U+2212 minus sign β†’ 0x2D minus
    • U+2216 set minus β†’ 0x5C backslash
    • U+2217 asterisk operator β†’ 0x2A asterisk
    • U+2223 divides β†’ 0x7C vertical line
    • U+2500 box drawing light horizontal β†’ 0x2D minus
    • U+2501 box drawing heavy horizontal β†’ 0x2D minus
    • U+2502 box drawing light vertical β†’ 0x7C vertical line
    • U+2503 box drawing heavy vertical β†’ 0x7C vertical line
    • U+2731 heavy asterisk β†’ 0x2A asterisk
    • U+275D heavy double turned comma quotation mark β†’ 0x22 double quote
    • U+275E heavy double comma quotation mark β†’ 0x22 double quote
    • U+3000 ideographic space β†’ 0x20 space
    • U+FE60 small ampersand β†’ 0x26 ampersand
    • U+FE61 small asterisk β†’ 0x2A asterisk
    • U+FE62 small plus sign β†’ 0x2B plus sign
  • -E β€” List the expansions performed by the -x flag. spill the tea on what -x does, she's not gatekeeping 🍡
  • -f β€” Convert stylistic variants to plain ASCII. Stylistic equivalents include: superscript and subscript forms, small capitals (e.g. U+1D04), script forms (e.g. U+212C), black letter forms (e.g. U+212D), fullwidth forms (e.g. U+FF01), halfwidth forms (e.g. U+FF7B), and the mathematical alphanumeric symbols (e.g. U+1D400). basically every fancy font your notes app offers? she's flattening all of them. sorry to the aesthetic 😭
  • -h β€” Help. Print the usage message and exit. when in doubt, ask her πŸ’¬
  • -l β€” Use lowercase a-f when generating hexadecimal numbers. lowercase is a vibe, honestly πŸ“
  • -n β€” Convert newlines too. By default, they are left alone. she respects the line break's boundaries unless you say otherwise 🚧
  • -P β€” Pass through Unicode rather than converting to ASCII escapes if the character is not converted to an ASCII character by a transformation such as diacritic stripping. Note that if this option is used the output may not be pure ASCII.
⚠️ heads up bestie β€” flip this on and your output might not be pure ASCII anymore. she's telling you upfront so you can't be mad later πŸ’€
  • -p β€” Pure. Convert characters within the ASCII range except for space and newline as well as those above. no survivors, everything gets processed πŸŽ€
  • -q β€” Quiet. Do not chat unnecessarily while working. she's locking in πŸ”‡
  • -s β€” Convert space characters too. By default, they are left alone. spaces get the same treatment as the newlines up there, iykyk ✨
  • -S <Unicode:ASCII> β€” Define a custom substitution. The argument should consist of the Unicode codepoint to be replaced followed by the ASCII code of the character to be used as replacement, separated by a colon. If no ASCII code follows the colon, the specified Unicode character will be deleted. The code values may be in hexadecimal, octal, or decimal following the usual conventions (to be precise, those of strtoul(3)). This option may be repeated as many times as desired to define multiple substitutions. build your own ruleset, custom queen behavior πŸ‘‘
  • -v β€” Print program version information and exit. know your version, always πŸ“Œ
  • -w β€” Add a space after each converted item. personal space bubble for every single escape sequence 🌸
  • -x β€” okay so bestie, this one expands certain characters to multicharacter sequences. The characters affected are the same as those affected by the -y option. Here's the whole list, no cap:
              U+00A2 CENT SIGN                        -> cent
              U+00A3 POUND SIGN                       -> pound
              U+00A5 YEN SIGN                         -> yen
              U+00A9 COPYRIGHT SYMBOL                 -> (c)
              U+00AE REGISTERED SYMBOL                -> (R)
              U+00BC ONE QUARTER                      -> 1/4
              U+00BD ONE HALF                         -> 1/2
              U+00BE THREE QUARTERS                   -> 3/4
              U+00C6 CAPITAL LETTER ASH               -> AE
              U+00DF SMALL LETTER SHARP S             -> ss
              U+00E6 SMALL LETTER ASH                 -> ae
              U+0132 LIGATURE IJ                      -> IJ
              U+0133 LIGATURE ij                      -> ij
              U+0152 LIGATURE OE                      -> OE
              U+0153 LIGATURE oe                      -> oe
              U+01F1 CAPITAL LETTER DZ                -> DZ
              U+01F2 MIXED LETTER Dz                  -> Dz
              U+01F3 SMALL LETTER DZ                  -> dz
              U+02A6 SMALL LETTER TS DIGRAPH          -> ts
              U+2026 HORIZONTAL ELLIPSIS              -> ...
              U+20AC EURO SIGN                        -> euro
              U+2122 TRADEMARK SIGN                   -> (tm) br U+22EF MIDLINE
              HORIZONTAL ELLIPSIS      -> ...
              U+2190 LEFTWARDS ARROW                  -> <-
              U+2192 RIGHTWARDS ARROW                 -> ->
              U+21D0 LEFTWARDS DOUBLE ARROW           -> <=
              U+21D2 RIGHTWARDS DOUBLE ARROW          -> =>
              U+FB00 LATIN SMALL LIGATURE FF          -> ff
              U+FB01 LATIN SMALL LIGATURE FI          -> fi
              U+FB02 LATIN SMALL LIGATURE FL          -> fl
              U+FB03 LATIN SMALL LIGATURE FFI         -> ffi
              U+FB04 LATIN SMALL LIGATURE FFL         -> ffl
              U+FB06 LATIN SMALL LIGATURE ST          -> st
  • -y β€” this one converts certain characters having multi-character expansions to single-character ascii approximations instead (e.g. to maintain character-positioning). The characters affected are the same as those affected by the -x option. It's giving compact vibes, fr fr:
              U+00A2 CENT SIGN                        -> c
              U+00A3 POUND SIGN                       -> #
              U+00A5 YEN SIGN                         -> Y
              U+00A9 COPYRIGHT SYMBOL                 -> C
              U+00AE REGISTERED SYMBOL                -> R
              U+00BC ONE QUARTER                      -> -
              U+00BD ONE HALF                         -> -
              U+00BE THREE QUARTERS                   -> -
              U+00C6 CAPITAL LETTER ASH               -> A
              U+00DF SMALL LETTER SHARP S             -> s
              U+00E6 SMALL LETTER ASH                 -> a
              U+0132 LIGATURE IJ                      -> I
              U+0133 LIGATURE ij                      -> i
              U+0152 LIGATURE OE                      -> O
              U+0153 LIGATURE oe                      -> o
              U+01F1 CAPITAL LETTER DZ                -> D
              U+01F2 MIXED LETTER Dz                  -> D
              U+01F3 SMALL LETTER DZ                  -> d
              U+02A6 SMALL LETTER TS DIGRAPH          -> t
              U+2026 HORIZONTAL ELLIPSIS              -> .
              U+20AC EURO SIGN                        -> E
              U+22EF MIDLINE HORIZONTAL ELLIPSIS      -> .
              U+2190 LEFTWARDS ARROW                  -> <
              U+2192 RIGHTWARDS ARROW                 -> >
              U+21D0 LEFTWARDS DOUBLE ARROW           -> <
              U+21D2 RIGHTWARDS DOUBLE ARROW          -> >
  • -Z <format> β€” generate output using the supplied format. The format specified will be used as the format string in a call to printf(3) with a single argument consisting of an unsigned long integer. For example, to obtain the same output as with the -U flag, the format would be: \u%04X.

If conversion of spaces is disabled (as it is by default), if space characters outside the ASCII range are encountered (U+3000 ideographic space, U+1351 Ethiopic word space, and U+1680 ogham space mark), they are replaced with the ASCII space character (0x20) so as to keep the output pure 7-bit ASCII. <sparkle>✨</sparkle>

Note that XML and XHTML numeric character entities are like those of HTML with two restrictions. First, in X(HT)ML the terminating semi-colon may not be omitted. Second, in X(HT)ML the "x" must be lower-case, while in HTML it may be either upper- or lower-case. We always generate the terminating semi-colon and use a lower-case "x", so the option dubbed "HTML" produces valid XML and XHTML as well. periodt.

πŸ’€ EXIT STATUS πŸ’€

The following values are returned on exit:

  • 0 SUCCESS β€” the input was successfully converted. πŸ’–
  • 2 I/O ERROR β€” a system error ocurred during input or output. 😭
  • 3 INFO β€” the user requested information such as the version number or usage synopsis and this has been provided. ✨
  • 5 BAD OPTION β€” an incorrect option flag was given on the command line. πŸ’…
  • 8 BAD RECORD β€” ill-formed UTF-8 was detected in the input. πŸ’€

πŸ‘€ SEE ALSO πŸ‘€

🫢 AUTHOR 🫢

Bill Poser <billposer@alum.mit.edu> β€” this icon wrote it. πŸ’–

πŸ“œ LICENSE πŸ“œ

GNU General Public License. That's it. No cap.

This page is from uni2ascii(1), dated August, 2013. Stay slay, bestie. πŸ’…βœ¨