Contents:

1. Introduction

This program defines two functions to encode and decode UTF-8 text to and from various other charsets and encodings.

2. Overview

encode-text takes a UTF-8 text string, and encodes it according to the specified encoding. (See List of supported encodings for the list of available encodings.) By default, a new string value is returned; you can use the /to refinement to have the function output the encoded string to the tail of the specified output string. This is a very useful optimization of the common idiom:

append output encode-text text 'ascii

which would copy the text twice; instead, you would use:

encode-text/to text 'ascii output

which is more efficient. Some encodings (see below) also support encoding in place; you can encode in place by passing the input string as output too:

encode-text/to text 'ascii text

Please note that if the specified encoding does not support encoding in place, an error will occur.

Overview

Support functions

encode-text: func [
 {Encode UTF-8 text to the specified encoding or charset} [catch]
 text [any-string!]
 encoding [word!] "Name of the target encoding - see docs"
 /to output [any-string!] "Output to this buffer"
 
 /local encode-text's locals
] [
 Encode text to the specified encoding
]

decode-text takes a string encoded with the specified encoding, and decodes it to UTF-8. By default a new string value is returned, but you can use the /to refinement in the same ways as shown above for the encode-text function.

Overview +≡

decode-text: func [
 {Decode text from the specified encoding or charset to UTF-8} [catch]
 text [any-string!]
 encoding [word!] "Name of TEXT's encoding or charset"
 /to output [any-string!] "Output to this buffer"
 
 /local decode-text's locals
] [
 Decode text from the specified encoding
]

3. Encode text to the specified encoding

We use the encoding word to get the object that defines the desired encoding from the encodings object defined in List of supported encodings. If encoding in place is desired, we check for the encode-inplace function in the encoding object; if it does not exist, it means that the encoding does not support encoding in place.

We also check if a custom encode function is available, and if so we just call it; otherwise, we use the parse-utf8 function to drive the encoding (see below).

Encode text to the specified encoding

unless encobj: get in encodings encoding [
 throw make error! join "Invalid encoding name: " encoding
]
unless output [output: make string! length? text]
either same? head text head output [
 unless enc: get in encobj 'encode-inplace [
  throw make error! rejoin [encoding " encoding does not support encoding in place"]
 ]
 enc text
] [
 either enc: get in encobj 'encode [
  enc output text
 ] [
  parse-utf8 text output encobj
 ]
]

3.1 encode-text's locals

encode-text's locals

encobj enc

4. Decode text from the specified encoding

The decode-text function works almost exactly like encode-text; we get the encoding object, and use decode-inplace if in place decoding is desired, and that is available; otherwise we just call the decode function.

Decode text from the specified encoding

unless encobj: get in encodings encoding [
 throw make error! join "Invalid encoding name: " encoding
]
unless output [output: make string! length? text]
either same? head text head output [
 unless dec: get in encobj 'decode-inplace [
  throw make error! rejoin [encoding " encoding does not support decoding in place"]
 ]
 dec text
] [
 encobj/decode output text
]

4.1 decode-text's locals

decode-text's locals

encobj dec

5. List of supported encodings

Here we define all the encoding objects that hold the actual encoding and decoding code. We use the make-encoding function as a shortcut to create them, see Support functions. See also parse-utf8 for how the object is used for encoding.

The utf-8 encoding is a no-op (obviously) and is provided for completeness.

List of supported encodings

utf-8: utf8: make-encoding none

The us-ascii encoding is a subset of UTF-8, so the encoding and decoding code is very simple. When encoding, we replace all non-ascii characters with a question mark.

List of supported encodings +≡

us-ascii: ascii: make-encoding [
 decode-inplace: func [text] [text]
 decode: func [output text] [append output text]
 encode-ascii: func [output start end] [insert/part tail output start end]
 encode-sequence: func [output start end] [append output #"?"]
]

The latin1 encoding can represent the first 256 Unicode code points directly. When encoding, we replace all characters above 255 with a question mark. Decoding in place is supported, since it is very common to have latin1 strings that are basically just ascii, which means that the decoding in place is very fast.

List of supported encodings +≡

iso-8859-1: latin1: make-encoding [
 decode-inplace: func [text /local mk1] [
  parse/all text [
   some [
    any ascii-char mk1: skip (mk1: change/part mk1 encode-utf8 to integer! mk1/1 next mk1) :mk1
   ]
  ]
  text
 ]
 decode: func [output text /local mk1 mk2] [
  parse/all text [
   some [
    mk1: some ascii-char mk2: (insert/part tail output mk1 mk2)
    |
    skip (append output encode-utf8 to integer! mk1/1)
   ]
  ]
  output
 ]
 encode-ascii: func [output start end] [insert/part tail output start end]
 encode-sequence: func [output start end] [
  start: decode-utf8 copy/part start end
  either start < 256 [
   append output to char! start
  ] [
   append output #"?"
  ]
 ]
]

The following are the other ISO-8859 8 bit charsets. We use a simple map since they are 8-bit encodings.

List of supported encodings +≡

iso-8859-2: latin2: make-encoding [
 #{00} #{01} #{02} #{03} #{04} #{05} #{06} #{07} #{08} #{09} #{0A}
 #{0B} #{0C} #{0D} #{0E} #{0F} #{10} #{11} #{12} #{13} #{14} #{15}
 #{16} #{17} #{18} #{19} #{1A} #{1B} #{1C} #{1D} #{1E} #{1F} #{20}
 #{21} #{22} #{23} #{24} #{25} #{26} #{27} #{28} #{29} #{2A} #{2B}
 #{2C} #{2D} #{2E} #{2F} #{30} #{31} #{32} #{33} #{34} #{35} #{36}
 #{37} #{38} #{39} #{3A} #{3B} #{3C} #{3D} #{3E} #{3F} #{40} #{41}
 #{42} #{43} #{44} #{45} #{46} #{47} #{48} #{49} #{4A} #{4B} #{4C}
 #{4D} #{4E} #{4F} #{50} #{51} #{52} #{53} #{54} #{55} #{56} #{57}
 #{58} #{59} #{5A} #{5B} #{5C} #{5D} #{5E} #{5F} #{60} #{61} #{62}
 #{63} #{64} #{65} #{66} #{67} #{68} #{69} #{6A} #{6B} #{6C} #{6D}
 #{6E} #{6F} #{70} #{71} #{72} #{73} #{74} #{75} #{76} #{77} #{78}
 #{79} #{7A} #{7B} #{7C} #{7D} #{7E} #{7F} #{C280} #{C281} #{C282}
 #{C283} #{C284} #{C285} #{C286} #{C287} #{C288} #{C289} #{C28A}
 #{C28B} #{C28C} #{C28D} #{C28E} #{C28F} #{C290} #{C291} #{C292}
 #{C293} #{C294} #{C295} #{C296} #{C297} #{C298} #{C299} #{C29A}
 #{C29B} #{C29C} #{C29D} #{C29E} #{C29F} #{C2A0} #{C484} #{CB98}
 #{C581} #{C2A4} #{C4BD} #{C59A} #{C2A7} #{C2A8} #{C5A0} #{C59E}
 #{C5A4} #{C5B9} #{C2AD} #{C5BD} #{C5BB} #{C2B0} #{C485} #{CB9B}
 #{C582} #{C2B4} #{C4BE} #{C59B} #{CB87} #{C2B8} #{C5A1} #{C59F}
 #{C5A5} #{C5BA} #{CB9D} #{C5BE} #{C5BC} #{C594} #{C381} #{C382}
 #{C482} #{C384} #{C4B9} #{C486} #{C387} #{C48C} #{C389} #{C498}
 #{C38B} #{C49A} #{C38D} #{C38E} #{C48E} #{C490} #{C583} #{C587}
 #{C393} #{C394} #{C590} #{C396} #{C397} #{C598} #{C5AE} #{C39A}
 #{C5B0} #{C39C} #{C39D} #{C5A2} #{C39F} #{C595} #{C3A1} #{C3A2}
 #{C483} #{C3A4} #{C4BA} #{C487} #{C3A7} #{C48D} #{C3A9} #{C499}
 #{C3AB} #{C49B} #{C3AD} #{C3AE} #{C48F} #{C491} #{C584} #{C588}
 #{C3B3} #{C3B4} #{C591} #{C3B6} #{C3B7} #{C599} #{C5AF} #{C3BA}
 #{C5B1} #{C3BC} #{C3BD} #{C5A3} #{CB99}
]
iso-8859-3: latin3: make-encoding [
 #{00} #{01} #{02} #{03} #{04} #{05} #{06} #{07} #{08} #{09} #{0A}
 #{0B} #{0C} #{0D} #{0E} #{0F} #{10} #{11} #{12} #{13} #{14} #{15}
 #{16} #{17} #{18} #{19} #{1A} #{1B} #{1C} #{1D} #{1E} #{1F} #{20}
 #{21} #{22} #{23} #{24} #{25} #{26} #{27} #{28} #{29} #{2A} #{2B}
 #{2C} #{2D} #{2E} #{2F} #{30} #{31} #{32} #{33} #{34} #{35} #{36}
 #{37} #{38} #{39} #{3A} #{3B} #{3C} #{3D} #{3E} #{3F} #{40} #{41}
 #{42} #{43} #{44} #{45} #{46} #{47} #{48} #{49} #{4A} #{4B} #{4C}
 #{4D} #{4E} #{4F} #{50} #{51} #{52} #{53} #{54} #{55} #{56} #{57}
 #{58} #{59} #{5A} #{5B} #{5C} #{5D} #{5E} #{5F} #{60} #{61} #{62}
 #{63} #{64} #{65} #{66} #{67} #{68} #{69} #{6A} #{6B} #{6C} #{6D}
 #{6E} #{6F} #{70} #{71} #{72} #{73} #{74} #{75} #{76} #{77} #{78}
 #{79} #{7A} #{7B} #{7C} #{7D} #{7E} #{7F} #{C280} #{C281} #{C282}
 #{C283} #{C284} #{C285} #{C286} #{C287} #{C288} #{C289} #{C28A}
 #{C28B} #{C28C} #{C28D} #{C28E} #{C28F} #{C290} #{C291} #{C292}
 #{C293} #{C294} #{C295} #{C296} #{C297} #{C298} #{C299} #{C29A}
 #{C29B} #{C29C} #{C29D} #{C29E} #{C29F} #{C2A0} #{C4A6} #{CB98}
 #{C2A3} #{C2A4} #{3F} #{C4A4} #{C2A7} #{C2A8} #{C4B0} #{C59E}
 #{C49E} #{C4B4} #{C2AD} #{3F} #{C5BB} #{C2B0} #{C4A7} #{C2B2}
 #{C2B3} #{C2B4} #{C2B5} #{C4A5} #{C2B7} #{C2B8} #{C4B1} #{C59F}
 #{C49F} #{C4B5} #{C2BD} #{3F} #{C5BC} #{C380} #{C381} #{C382}
 #{3F} #{C384} #{C48A} #{C488} #{C387} #{C388} #{C389} #{C38A}
 #{C38B} #{C38C} #{C38D} #{C38E} #{C38F} #{3F} #{C391} #{C392}
 #{C393} #{C394} #{C4A0} #{C396} #{C397} #{C49C} #{C399} #{C39A}
 #{C39B} #{C39C} #{C5AC} #{C59C} #{C39F} #{C3A0} #{C3A1} #{C3A2}
 #{3F} #{C3A4} #{C48B} #{C489} #{C3A7} #{C3A8} #{C3A9} #{C3AA}
 #{C3AB} #{C3AC} #{C3AD} #{C3AE} #{C3AF} #{3F} #{C3B1} #{C3B2}
 #{C3B3} #{C3B4} #{C4A1} #{C3B6} #{C3B7} #{C49D} #{C3B9} #{C3BA}
 #{C3BB} #{C3BC} #{C5AD} #{C59D} #{CB99}
]
iso-8859-4: latin4: make-encoding [
 #{00} #{01} #{02} #{03} #{04} #{05} #{06} #{07} #{08} #{09} #{0A}
 #{0B} #{0C} #{0D} #{0E} #{0F} #{10} #{11} #{12} #{13} #{14} #{15}
 #{16} #{17} #{18} #{19} #{1A} #{1B} #{1C} #{1D} #{1E} #{1F} #{20}
 #{21} #{22} #{23} #{24} #{25} #{26} #{27} #{28} #{29} #{2A} #{2B}
 #{2C} #{2D} #{2E} #{2F} #{30} #{31} #{32} #{33} #{34} #{35} #{36}
 #{37} #{38} #{39} #{3A} #{3B} #{3C} #{3D} #{3E} #{3F} #{40} #{41}
 #{42} #{43} #{44} #{45} #{46} #{47} #{48} #{49} #{4A} #{4B} #{4C}
 #{4D} #{4E} #{4F} #{50} #{51} #{52} #{53} #{54} #{55} #{56} #{57}
 #{58} #{59} #{5A} #{5B} #{5C} #{5D} #{5E} #{5F} #{60} #{61} #{62}
 #{63} #{64} #{65} #{66} #{67} #{68} #{69} #{6A} #{6B} #{6C} #{6D}
 #{6E} #{6F} #{70} #{71} #{72} #{73} #{74} #{75} #{76} #{77} #{78}
 #{79} #{7A} #{7B} #{7C} #{7D} #{7E} #{7F} #{C280} #{C281} #{C282}
 #{C283} #{C284} #{C285} #{C286} #{C287} #{C288} #{C289} #{C28A}
 #{C28B} #{C28C} #{C28D} #{C28E} #{C28F} #{C290} #{C291} #{C292}
 #{C293} #{C294} #{C295} #{C296} #{C297} #{C298} #{C299} #{C29A}
 #{C29B} #{C29C} #{C29D} #{C29E} #{C29F} #{C2A0} #{C484} #{C4B8}
 #{C596} #{C2A4} #{C4A8} #{C4BB} #{C2A7} #{C2A8} #{C5A0} #{C492}
 #{C4A2} #{C5A6} #{C2AD} #{C5BD} #{C2AF} #{C2B0} #{C485} #{CB9B}
 #{C597} #{C2B4} #{C4A9} #{C4BC} #{CB87} #{C2B8} #{C5A1} #{C493}
 #{C4A3} #{C5A7} #{C58A} #{C5BE} #{C58B} #{C480} #{C381} #{C382}
 #{C383} #{C384} #{C385} #{C386} #{C4AE} #{C48C} #{C389} #{C498}
 #{C38B} #{C496} #{C38D} #{C38E} #{C4AA} #{C490} #{C585} #{C58C}
 #{C4B6} #{C394} #{C395} #{C396} #{C397} #{C398} #{C5B2} #{C39A}
 #{C39B} #{C39C} #{C5A8} #{C5AA} #{C39F} #{C481} #{C3A1} #{C3A2}
 #{C3A3} #{C3A4} #{C3A5} #{C3A6} #{C4AF} #{C48D} #{C3A9} #{C499}
 #{C3AB} #{C497} #{C3AD} #{C3AE} #{C4AB} #{C491} #{C586} #{C58D}
 #{C4B7} #{C3B4} #{C3B5} #{C3B6} #{C3B7} #{C3B8} #{C5B3} #{C3BA}
 #{C3BB} #{C3BC} #{C5A9} #{C5AB} #{CB99}
]
iso-8859-5: cyrillic: make-encoding [
 #{00} #{01} #{02} #{03} #{04} #{05} #{06} #{07} #{08} #{09} #{0A}
 #{0B} #{0C} #{0D} #{0E} #{0F} #{10} #{11} #{12} #{13} #{14} #{15}
 #{16} #{17} #{18} #{19} #{1A} #{1B} #{1C} #{1D} #{1E} #{1F} #{20}
 #{21} #{22} #{23} #{24} #{25} #{26} #{27} #{28} #{29} #{2A} #{2B}
 #{2C} #{2D} #{2E} #{2F} #{30} #{31} #{32} #{33} #{34} #{35} #{36}
 #{37} #{38} #{39} #{3A} #{3B} #{3C} #{3D} #{3E} #{3F} #{40} #{41}
 #{42} #{43} #{44} #{45} #{46} #{47} #{48} #{49} #{4A} #{4B} #{4C}
 #{4D} #{4E} #{4F} #{50} #{51} #{52} #{53} #{54} #{55} #{56} #{57}
 #{58} #{59} #{5A} #{5B} #{5C} #{5D} #{5E} #{5F} #{60} #{61} #{62}
 #{63} #{64} #{65} #{66} #{67} #{68} #{69} #{6A} #{6B} #{6C} #{6D}
 #{6E} #{6F} #{70} #{71} #{72} #{73} #{74} #{75} #{76} #{77} #{78}
 #{79} #{7A} #{7B} #{7C} #{7D} #{7E} #{7F} #{C280} #{C281} #{C282}
 #{C283} #{C284} #{C285} #{C286} #{C287} #{C288} #{C289} #{C28A}
 #{C28B} #{C28C} #{C28D} #{C28E} #{C28F} #{C290} #{C291} #{C292}
 #{C293} #{C294} #{C295} #{C296} #{C297} #{C298} #{C299} #{C29A}
 #{C29B} #{C29C} #{C29D} #{C29E} #{C29F} #{C2A0} #{D081} #{D082}
 #{D083} #{D084} #{D085} #{D086} #{D087} #{D088} #{D089} #{D08A}
 #{D08B} #{D08C} #{C2AD} #{D08E} #{D08F} #{D090} #{D091} #{D092}
 #{D093} #{D094} #{D095} #{D096} #{D097} #{D098} #{D099} #{D09A}
 #{D09B} #{D09C} #{D09D} #{D09E} #{D09F} #{D0A0} #{D0A1} #{D0A2}
 #{D0A3} #{D0A4} #{D0A5} #{D0A6} #{D0A7} #{D0A8} #{D0A9} #{D0AA}
 #{D0AB} #{D0AC} #{D0AD} #{D0AE} #{D0AF} #{D0B0} #{D0B1} #{D0B2}
 #{D0B3} #{D0B4} #{D0B5} #{D0B6} #{D0B7} #{D0B8} #{D0B9} #{D0BA}
 #{D0BB} #{D0BC} #{D0BD} #{D0BE} #{D0BF} #{D180} #{D181} #{D182}
 #{D183} #{D184} #{D185} #{D186} #{D187} #{D188} #{D189} #{D18A}
 #{D18B} #{D18C} #{D18D} #{D18E} #{D18F} #{E28496} #{D191} #{D192}
 #{D193} #{D194} #{D195} #{D196} #{D197} #{D198} #{D199} #{D19A}
 #{D19B} #{D19C} #{C2A7} #{D19E} #{D19F}
]
iso-8859-6: arabic: make-encoding [
 #{00} #{01} #{02} #{03} #{04} #{05} #{06} #{07} #{08} #{09} #{0A}
 #{0B} #{0C} #{0D} #{0E} #{0F} #{10} #{11} #{12} #{13} #{14} #{15}
 #{16} #{17} #{18} #{19} #{1A} #{1B} #{1C} #{1D} #{1E} #{1F} #{20}
 #{21} #{22} #{23} #{24} #{25} #{26} #{27} #{28} #{29} #{2A} #{2B}
 #{2C} #{2D} #{2E} #{2F} #{30} #{31} #{32} #{33} #{34} #{35} #{36}
 #{37} #{38} #{39} #{3A} #{3B} #{3C} #{3D} #{3E} #{3F} #{40} #{41}
 #{42} #{43} #{44} #{45} #{46} #{47} #{48} #{49} #{4A} #{4B} #{4C}
 #{4D} #{4E} #{4F} #{50} #{51} #{52} #{53} #{54} #{55} #{56} #{57}
 #{58} #{59} #{5A} #{5B} #{5C} #{5D} #{5E} #{5F} #{60} #{61} #{62}
 #{63} #{64} #{65} #{66} #{67} #{68} #{69} #{6A} #{6B} #{6C} #{6D}
 #{6E} #{6F} #{70} #{71} #{72} #{73} #{74} #{75} #{76} #{77} #{78}
 #{79} #{7A} #{7B} #{7C} #{7D} #{7E} #{7F} #{C280} #{C281} #{C282}
 #{C283} #{C284} #{C285} #{C286} #{C287} #{C288} #{C289} #{C28A}
 #{C28B} #{C28C} #{C28D} #{C28E} #{C28F} #{C290} #{C291} #{C292}
 #{C293} #{C294} #{C295} #{C296} #{C297} #{C298} #{C299} #{C29A}
 #{C29B} #{C29C} #{C29D} #{C29E} #{C29F} #{C2A0} #{3F} #{3F} #{3F}
 #{C2A4} #{3F} #{3F} #{3F} #{3F} #{3F} #{3F} #{3F} #{D88C} #{C2AD}
 #{3F} #{3F} #{3F} #{3F} #{3F} #{3F} #{3F} #{3F} #{3F} #{3F} #{3F}
 #{3F} #{3F} #{D89B} #{3F} #{3F} #{3F} #{D89F} #{3F} #{D8A1}
 #{D8A2} #{D8A3} #{D8A4} #{D8A5} #{D8A6} #{D8A7} #{D8A8} #{D8A9}
 #{D8AA} #{D8AB} #{D8AC} #{D8AD} #{D8AE} #{D8AF} #{D8B0} #{D8B1}
 #{D8B2} #{D8B3} #{D8B4} #{D8B5} #{D8B6} #{D8B7} #{D8B8} #{D8B9}
 #{D8BA} #{3F} #{3F} #{3F} #{3F} #{3F} #{D980} #{D981} #{D982}
 #{D983} #{D984} #{D985} #{D986} #{D987} #{D988} #{D989} #{D98A}
 #{D98B} #{D98C} #{D98D} #{D98E} #{D98F} #{D990} #{D991} #{D992}
 #{3F} #{3F} #{3F} #{3F} #{3F} #{3F} #{3F} #{3F} #{3F} #{3F} #{3F}
 #{3F} #{3F}
]
iso-8859-7: greek: make-encoding [
 #{00} #{01} #{02} #{03} #{04} #{05} #{06} #{07} #{08} #{09} #{0A}
 #{0B} #{0C} #{0D} #{0E} #{0F} #{10} #{11} #{12} #{13} #{14} #{15}
 #{16} #{17} #{18} #{19} #{1A} #{1B} #{1C} #{1D} #{1E} #{1F} #{20}
 #{21} #{22} #{23} #{24} #{25} #{26} #{27} #{28} #{29} #{2A} #{2B}
 #{2C} #{2D} #{2E} #{2F} #{30} #{31} #{32} #{33} #{34} #{35} #{36}
 #{37} #{38} #{39} #{3A} #{3B} #{3C} #{3D} #{3E} #{3F} #{40} #{41}
 #{42} #{43} #{44} #{45} #{46} #{47} #{48} #{49} #{4A} #{4B} #{4C}
 #{4D} #{4E} #{4F} #{50} #{51} #{52} #{53} #{54} #{55} #{56} #{57}
 #{58} #{59} #{5A} #{5B} #{5C} #{5D} #{5E} #{5F} #{60} #{61} #{62}
 #{63} #{64} #{65} #{66} #{67} #{68} #{69} #{6A} #{6B} #{6C} #{6D}
 #{6E} #{6F} #{70} #{71} #{72} #{73} #{74} #{75} #{76} #{77} #{78}
 #{79} #{7A} #{7B} #{7C} #{7D} #{7E} #{7F} #{C280} #{C281} #{C282}
 #{C283} #{C284} #{C285} #{C286} #{C287} #{C288} #{C289} #{C28A}
 #{C28B} #{C28C} #{C28D} #{C28E} #{C28F} #{C290} #{C291} #{C292}
 #{C293} #{C294} #{C295} #{C296} #{C297} #{C298} #{C299} #{C29A}
 #{C29B} #{C29C} #{C29D} #{C29E} #{C29F} #{C2A0} #{E28098}
 #{E28099} #{C2A3} #{E282AC} #{E282AF} #{C2A6} #{C2A7} #{C2A8}
 #{C2A9} #{CDBA} #{C2AB} #{C2AC} #{C2AD} #{3F} #{E28095} #{C2B0}
 #{C2B1} #{C2B2} #{C2B3} #{CE84} #{CE85} #{CE86} #{C2B7} #{CE88}
 #{CE89} #{CE8A} #{C2BB} #{CE8C} #{C2BD} #{CE8E} #{CE8F} #{CE90}
 #{CE91} #{CE92} #{CE93} #{CE94} #{CE95} #{CE96} #{CE97} #{CE98}
 #{CE99} #{CE9A} #{CE9B} #{CE9C} #{CE9D} #{CE9E} #{CE9F} #{CEA0}
 #{CEA1} #{3F} #{CEA3} #{CEA4} #{CEA5} #{CEA6} #{CEA7} #{CEA8}
 #{CEA9} #{CEAA} #{CEAB} #{CEAC} #{CEAD} #{CEAE} #{CEAF} #{CEB0}
 #{CEB1} #{CEB2} #{CEB3} #{CEB4} #{CEB5} #{CEB6} #{CEB7} #{CEB8}
 #{CEB9} #{CEBA} #{CEBB} #{CEBC} #{CEBD} #{CEBE} #{CEBF} #{CF80}
 #{CF81} #{CF82} #{CF83} #{CF84} #{CF85} #{CF86} #{CF87} #{CF88}
 #{CF89} #{CF8A} #{CF8B} #{CF8C} #{CF8D} #{CF8E} #{3F}
]
iso-8859-8: hebrew: make-encoding [
 #{00} #{01} #{02} #{03} #{04} #{05} #{06} #{07} #{08} #{09} #{0A}
 #{0B} #{0C} #{0D} #{0E} #{0F} #{10} #{11} #{12} #{13} #{14} #{15}
 #{16} #{17} #{18} #{19} #{1A} #{1B} #{1C} #{1D} #{1E} #{1F} #{20}
 #{21} #{22} #{23} #{24} #{25} #{26} #{27} #{28} #{29} #{2A} #{2B}
 #{2C} #{2D} #{2E} #{2F} #{30} #{31} #{32} #{33} #{34} #{35} #{36}
 #{37} #{38} #{39} #{3A} #{3B} #{3C} #{3D} #{3E} #{3F} #{40} #{41}
 #{42} #{43} #{44} #{45} #{46} #{47} #{48} #{49} #{4A} #{4B} #{4C}
 #{4D} #{4E} #{4F} #{50} #{51} #{52} #{53} #{54} #{55} #{56} #{57}
 #{58} #{59} #{5A} #{5B} #{5C} #{5D} #{5E} #{5F} #{60} #{61} #{62}
 #{63} #{64} #{65} #{66} #{67} #{68} #{69} #{6A} #{6B} #{6C} #{6D}
 #{6E} #{6F} #{70} #{71} #{72} #{73} #{74} #{75} #{76} #{77} #{78}
 #{79} #{7A} #{7B} #{7C} #{7D} #{7E} #{7F} #{C280} #{C281} #{C282}
 #{C283} #{C284} #{C285} #{C286} #{C287} #{C288} #{C289} #{C28A}
 #{C28B} #{C28C} #{C28D} #{C28E} #{C28F} #{C290} #{C291} #{C292}
 #{C293} #{C294} #{C295} #{C296} #{C297} #{C298} #{C299} #{C29A}
 #{C29B} #{C29C} #{C29D} #{C29E} #{C29F} #{C2A0} #{3F} #{C2A2}
 #{C2A3} #{C2A4} #{C2A5} #{C2A6} #{C2A7} #{C2A8} #{C2A9} #{C397}
 #{C2AB} #{C2AC} #{C2AD} #{C2AE} #{C2AF} #{C2B0} #{C2B1} #{C2B2}
 #{C2B3} #{C2B4} #{C2B5} #{C2B6} #{C2B7} #{C2B8} #{C2B9} #{C3B7}
 #{C2BB} #{C2BC} #{C2BD} #{C2BE} #{3F} #{3F} #{3F} #{3F} #{3F}
 #{3F} #{3F} #{3F} #{3F} #{3F} #{3F} #{3F} #{3F} #{3F} #{3F} #{3F}
 #{3F} #{3F} #{3F} #{3F} #{3F} #{3F} #{3F} #{3F} #{3F} #{3F} #{3F}
 #{3F} #{3F} #{3F} #{3F} #{3F} #{E28097} #{D790} #{D791} #{D792}
 #{D793} #{D794} #{D795} #{D796} #{D797} #{D798} #{D799} #{D79A}
 #{D79B} #{D79C} #{D79D} #{D79E} #{D79F} #{D7A0} #{D7A1} #{D7A2}
 #{D7A3} #{D7A4} #{D7A5} #{D7A6} #{D7A7} #{D7A8} #{D7A9} #{D7AA}
 #{3F} #{3F} #{E2808E} #{E2808F} #{3F}
]
iso-8859-9: latin5: make-encoding [
 #{00} #{01} #{02} #{03} #{04} #{05} #{06} #{07} #{08} #{09} #{0A}
 #{0B} #{0C} #{0D} #{0E} #{0F} #{10} #{11} #{12} #{13} #{14} #{15}
 #{16} #{17} #{18} #{19} #{1A} #{1B} #{1C} #{1D} #{1E} #{1F} #{20}
 #{21} #{22} #{23} #{24} #{25} #{26} #{27} #{28} #{29} #{2A} #{2B}
 #{2C} #{2D} #{2E} #{2F} #{30} #{31} #{32} #{33} #{34} #{35} #{36}
 #{37} #{38} #{39} #{3A} #{3B} #{3C} #{3D} #{3E} #{3F} #{40} #{41}
 #{42} #{43} #{44} #{45} #{46} #{47} #{48} #{49} #{4A} #{4B} #{4C}
 #{4D} #{4E} #{4F} #{50} #{51} #{52} #{53} #{54} #{55} #{56} #{57}
 #{58} #{59} #{5A} #{5B} #{5C} #{5D} #{5E} #{5F} #{60} #{61} #{62}
 #{63} #{64} #{65} #{66} #{67} #{68} #{69} #{6A} #{6B} #{6C} #{6D}
 #{6E} #{6F} #{70} #{71} #{72} #{73} #{74} #{75} #{76} #{77} #{78}
 #{79} #{7A} #{7B} #{7C} #{7D} #{7E} #{7F} #{C280} #{C281} #{C282}
 #{C283} #{C284} #{C285} #{C286} #{C287} #{C288} #{C289} #{C28A}
 #{C28B} #{C28C} #{C28D} #{C28E} #{C28F} #{C290} #{C291} #{C292}
 #{C293} #{C294} #{C295} #{C296} #{C297} #{C298} #{C299} #{C29A}
 #{C29B} #{C29C} #{C29D} #{C29E} #{C29F} #{C2A0} #{C2A1} #{C2A2}
 #{C2A3} #{C2A4} #{C2A5} #{C2A6} #{C2A7} #{C2A8} #{C2A9} #{C2AA}
 #{C2AB} #{C2AC} #{C2AD} #{C2AE} #{C2AF} #{C2B0} #{C2B1} #{C2B2}
 #{C2B3} #{C2B4} #{C2B5} #{C2B6} #{C2B7} #{C2B8} #{C2B9} #{C2BA}
 #{C2BB} #{C2BC} #{C2BD} #{C2BE} #{C2BF} #{C380} #{C381} #{C382}
 #{C383} #{C384} #{C385} #{C386} #{C387} #{C388} #{C389} #{C38A}
 #{C38B} #{C38C} #{C38D} #{C38E} #{C38F} #{C49E} #{C391} #{C392}
 #{C393} #{C394} #{C395} #{C396} #{C397} #{C398} #{C399} #{C39A}
 #{C39B} #{C39C} #{C4B0} #{C59E} #{C39F} #{C3A0} #{C3A1} #{C3A2}
 #{C3A3} #{C3A4} #{C3A5} #{C3A6} #{C3A7} #{C3A8} #{C3A9} #{C3AA}
 #{C3AB} #{C3AC} #{C3AD} #{C3AE} #{C3AF} #{C49F} #{C3B1} #{C3B2}
 #{C3B3} #{C3B4} #{C3B5} #{C3B6} #{C3B7} #{C3B8} #{C3B9} #{C3BA}
 #{C3BB} #{C3BC} #{C4B1} #{C59F} #{C3BF}
]
iso-8859-10: latin6: make-encoding [
 #{00} #{01} #{02} #{03} #{04} #{05} #{06} #{07} #{08} #{09} #{0A}
 #{0B} #{0C} #{0D} #{0E} #{0F} #{10} #{11} #{12} #{13} #{14} #{15}
 #{16} #{17} #{18} #{19} #{1A} #{1B} #{1C} #{1D} #{1E} #{1F} #{20}
 #{21} #{22} #{23} #{24} #{25} #{26} #{27} #{28} #{29} #{2A} #{2B}
 #{2C} #{2D} #{2E} #{2F} #{30} #{31} #{32} #{33} #{34} #{35} #{36}
 #{37} #{38} #{39} #{3A} #{3B} #{3C} #{3D} #{3E} #{3F} #{40} #{41}
 #{42} #{43} #{44} #{45} #{46} #{47} #{48} #{49} #{4A} #{4B} #{4C}
 #{4D} #{4E} #{4F} #{50} #{51} #{52} #{53} #{54} #{55} #{56} #{57}
 #{58} #{59} #{5A} #{5B} #{5C} #{5D} #{5E} #{5F} #{60} #{61} #{62}
 #{63} #{64} #{65} #{66} #{67} #{68} #{69} #{6A} #{6B} #{6C} #{6D}
 #{6E} #{6F} #{70} #{71} #{72} #{73} #{74} #{75} #{76} #{77} #{78}
 #{79} #{7A} #{7B} #{7C} #{7D} #{7E} #{7F} #{C280} #{C281} #{C282}
 #{C283} #{C284} #{C285} #{C286} #{C287} #{C288} #{C289} #{C28A}
 #{C28B} #{C28C} #{C28D} #{C28E} #{C28F} #{C290} #{C291} #{C292}
 #{C293} #{C294} #{C295} #{C296} #{C297} #{C298} #{C299} #{C29A}
 #{C29B} #{C29C} #{C29D} #{C29E} #{C29F} #{C2A0} #{C484} #{C492}
 #{C4A2} #{C4AA} #{C4A8} #{C4B6} #{C2A7} #{C4BB} #{C490} #{C5A0}
 #{C5A6} #{C5BD} #{C2AD} #{C5AA} #{C58A} #{C2B0} #{C485} #{C493}
 #{C4A3} #{C4AB} #{C4A9} #{C4B7} #{C2B7} #{C4BC} #{C491} #{C5A1}
 #{C5A7} #{C5BE} #{E28095} #{C5AB} #{C58B} #{C480} #{C381} #{C382}
 #{C383} #{C384} #{C385} #{C386} #{C4AE} #{C48C} #{C389} #{C498}
 #{C38B} #{C496} #{C38D} #{C38E} #{C38F} #{C390} #{C585} #{C58C}
 #{C393} #{C394} #{C395} #{C396} #{C5A8} #{C398} #{C5B2} #{C39A}
 #{C39B} #{C39C} #{C39D} #{C39E} #{C39F} #{C481} #{C3A1} #{C3A2}
 #{C3A3} #{C3A4} #{C3A5} #{C3A6} #{C4AF} #{C48D} #{C3A9} #{C499}
 #{C3AB} #{C497} #{C3AD} #{C3AE} #{C3AF} #{C3B0} #{C586} #{C58D}
 #{C3B3} #{C3B4} #{C3B5} #{C3B6} #{C5A9} #{C3B8} #{C5B3} #{C3BA}
 #{C3BB} #{C3BC} #{C3BD} #{C3BE} #{C4B8}
]
iso-8859-11: make-encoding [
 #{00} #{01} #{02} #{03} #{04} #{05} #{06} #{07} #{08} #{09} #{0A}
 #{0B} #{0C} #{0D} #{0E} #{0F} #{10} #{11} #{12} #{13} #{14} #{15}
 #{16} #{17} #{18} #{19} #{1A} #{1B} #{1C} #{1D} #{1E} #{1F} #{20}
 #{21} #{22} #{23} #{24} #{25} #{26} #{27} #{28} #{29} #{2A} #{2B}
 #{2C} #{2D} #{2E} #{2F} #{30} #{31} #{32} #{33} #{34} #{35} #{36}
 #{37} #{38} #{39} #{3A} #{3B} #{3C} #{3D} #{3E} #{3F} #{40} #{41}
 #{42} #{43} #{44} #{45} #{46} #{47} #{48} #{49} #{4A} #{4B} #{4C}
 #{4D} #{4E} #{4F} #{50} #{51} #{52} #{53} #{54} #{55} #{56} #{57}
 #{58} #{59} #{5A} #{5B} #{5C} #{5D} #{5E} #{5F} #{60} #{61} #{62}
 #{63} #{64} #{65} #{66} #{67} #{68} #{69} #{6A} #{6B} #{6C} #{6D}
 #{6E} #{6F} #{70} #{71} #{72} #{73} #{74} #{75} #{76} #{77} #{78}
 #{79} #{7A} #{7B} #{7C} #{7D} #{7E} #{7F} #{C280} #{C281} #{C282}
 #{C283} #{C284} #{C285} #{C286} #{C287} #{C288} #{C289} #{C28A}
 #{C28B} #{C28C} #{C28D} #{C28E} #{C28F} #{C290} #{C291} #{C292}
 #{C293} #{C294} #{C295} #{C296} #{C297} #{C298} #{C299} #{C29A}
 #{C29B} #{C29C} #{C29D} #{C29E} #{C29F} #{C2A0} #{E0B881}
 #{E0B882} #{E0B883} #{E0B884} #{E0B885} #{E0B886} #{E0B887}
 #{E0B888} #{E0B889} #{E0B88A} #{E0B88B} #{E0B88C} #{E0B88D}
 #{E0B88E} #{E0B88F} #{E0B890} #{E0B891} #{E0B892} #{E0B893}
 #{E0B894} #{E0B895} #{E0B896} #{E0B897} #{E0B898} #{E0B899}
 #{E0B89A} #{E0B89B} #{E0B89C} #{E0B89D} #{E0B89E} #{E0B89F}
 #{E0B8A0} #{E0B8A1} #{E0B8A2} #{E0B8A3} #{E0B8A4} #{E0B8A5}
 #{E0B8A6} #{E0B8A7} #{E0B8A8} #{E0B8A9} #{E0B8AA} #{E0B8AB}
 #{E0B8AC} #{E0B8AD} #{E0B8AE} #{E0B8AF} #{E0B8B0} #{E0B8B1}
 #{E0B8B2} #{E0B8B3} #{E0B8B4} #{E0B8B5} #{E0B8B6} #{E0B8B7}
 #{E0B8B8} #{E0B8B9} #{E0B8BA} #{3F} #{3F} #{3F} #{3F} #{E0B8BF}
 #{E0B980} #{E0B981} #{E0B982} #{E0B983} #{E0B984} #{E0B985}
 #{E0B986} #{E0B987} #{E0B988} #{E0B989} #{E0B98A} #{E0B98B}
 #{E0B98C} #{E0B98D} #{E0B98E} #{E0B98F} #{E0B990} #{E0B991}
 #{E0B992} #{E0B993} #{E0B994} #{E0B995} #{E0B996} #{E0B997}
 #{E0B998} #{E0B999} #{E0B99A} #{E0B99B} #{3F} #{3F} #{3F} #{3F}
]
iso-8859-13: make-encoding [
 #{00} #{01} #{02} #{03} #{04} #{05} #{06} #{07} #{08} #{09} #{0A}
 #{0B} #{0C} #{0D} #{0E} #{0F} #{10} #{11} #{12} #{13} #{14} #{15}
 #{16} #{17} #{18} #{19} #{1A} #{1B} #{1C} #{1D} #{1E} #{1F} #{20}
 #{21} #{22} #{23} #{24} #{25} #{26} #{27} #{28} #{29} #{2A} #{2B}
 #{2C} #{2D} #{2E} #{2F} #{30} #{31} #{32} #{33} #{34} #{35} #{36}
 #{37} #{38} #{39} #{3A} #{3B} #{3C} #{3D} #{3E} #{3F} #{40} #{41}
 #{42} #{43} #{44} #{45} #{46} #{47} #{48} #{49} #{4A} #{4B} #{4C}
 #{4D} #{4E} #{4F} #{50} #{51} #{52} #{53} #{54} #{55} #{56} #{57}
 #{58} #{59} #{5A} #{5B} #{5C} #{5D} #{5E} #{5F} #{60} #{61} #{62}
 #{63} #{64} #{65} #{66} #{67} #{68} #{69} #{6A} #{6B} #{6C} #{6D}
 #{6E} #{6F} #{70} #{71} #{72} #{73} #{74} #{75} #{76} #{77} #{78}
 #{79} #{7A} #{7B} #{7C} #{7D} #{7E} #{7F} #{C280} #{C281} #{C282}
 #{C283} #{C284} #{C285} #{C286} #{C287} #{C288} #{C289} #{C28A}
 #{C28B} #{C28C} #{C28D} #{C28E} #{C28F} #{C290} #{C291} #{C292}
 #{C293} #{C294} #{C295} #{C296} #{C297} #{C298} #{C299} #{C29A}
 #{C29B} #{C29C} #{C29D} #{C29E} #{C29F} #{C2A0} #{E2809D} #{C2A2}
 #{C2A3} #{C2A4} #{E2809E} #{C2A6} #{C2A7} #{C398} #{C2A9} #{C596}
 #{C2AB} #{C2AC} #{C2AD} #{C2AE} #{C386} #{C2B0} #{C2B1} #{C2B2}
 #{C2B3} #{E2809C} #{C2B5} #{C2B6} #{C2B7} #{C3B8} #{C2B9} #{C597}
 #{C2BB} #{C2BC} #{C2BD} #{C2BE} #{C3A6} #{C484} #{C4AE} #{C480}
 #{C486} #{C384} #{C385} #{C498} #{C492} #{C48C} #{C389} #{C5B9}
 #{C496} #{C4A2} #{C4B6} #{C4AA} #{C4BB} #{C5A0} #{C583} #{C585}
 #{C393} #{C58C} #{C395} #{C396} #{C397} #{C5B2} #{C581} #{C59A}
 #{C5AA} #{C39C} #{C5BB} #{C5BD} #{C39F} #{C485} #{C4AF} #{C481}
 #{C487} #{C3A4} #{C3A5} #{C499} #{C493} #{C48D} #{C3A9} #{C5BA}
 #{C497} #{C4A3} #{C4B7} #{C4AB} #{C4BC} #{C5A1} #{C584} #{C586}
 #{C3B3} #{C58D} #{C3B5} #{C3B6} #{C3B7} #{C5B3} #{C582} #{C59B}
 #{C5AB} #{C3BC} #{C5BC} #{C5BE} #{E28099}
]
iso-8859-14: latin8: make-encoding [
 #{00} #{01} #{02} #{03} #{04} #{05} #{06} #{07} #{08} #{09} #{0A}
 #{0B} #{0C} #{0D} #{0E} #{0F} #{10} #{11} #{12} #{13} #{14} #{15}
 #{16} #{17} #{18} #{19} #{1A} #{1B} #{1C} #{1D} #{1E} #{1F} #{20}
 #{21} #{22} #{23} #{24} #{25} #{26} #{27} #{28} #{29} #{2A} #{2B}
 #{2C} #{2D} #{2E} #{2F} #{30} #{31} #{32} #{33} #{34} #{35} #{36}
 #{37} #{38} #{39} #{3A} #{3B} #{3C} #{3D} #{3E} #{3F} #{40} #{41}
 #{42} #{43} #{44} #{45} #{46} #{47} #{48} #{49} #{4A} #{4B} #{4C}
 #{4D} #{4E} #{4F} #{50} #{51} #{52} #{53} #{54} #{55} #{56} #{57}
 #{58} #{59} #{5A} #{5B} #{5C} #{5D} #{5E} #{5F} #{60} #{61} #{62}
 #{63} #{64} #{65} #{66} #{67} #{68} #{69} #{6A} #{6B} #{6C} #{6D}
 #{6E} #{6F} #{70} #{71} #{72} #{73} #{74} #{75} #{76} #{77} #{78}
 #{79} #{7A} #{7B} #{7C} #{7D} #{7E} #{7F} #{C280} #{C281} #{C282}
 #{C283} #{C284} #{C285} #{C286} #{C287} #{C288} #{C289} #{C28A}
 #{C28B} #{C28C} #{C28D} #{C28E} #{C28F} #{C290} #{C291} #{C292}
 #{C293} #{C294} #{C295} #{C296} #{C297} #{C298} #{C299} #{C29A}
 #{C29B} #{C29C} #{C29D} #{C29E} #{C29F} #{C2A0} #{E1B882}
 #{E1B883} #{C2A3} #{C48A} #{C48B} #{E1B88A} #{C2A7} #{E1BA80}
 #{C2A9} #{E1BA82} #{E1B88B} #{E1BBB2} #{C2AD} #{C2AE} #{C5B8}
 #{E1B89E} #{E1B89F} #{C4A0} #{C4A1} #{E1B980} #{E1B981} #{C2B6}
 #{E1B996} #{E1BA81} #{E1B997} #{E1BA83} #{E1B9A0} #{E1BBB3}
 #{E1BA84} #{E1BA85} #{E1B9A1} #{C380} #{C381} #{C382} #{C383}
 #{C384} #{C385} #{C386} #{C387} #{C388} #{C389} #{C38A} #{C38B}
 #{C38C} #{C38D} #{C38E} #{C38F} #{C5B4} #{C391} #{C392} #{C393}
 #{C394} #{C395} #{C396} #{E1B9AA} #{C398} #{C399} #{C39A} #{C39B}
 #{C39C} #{C39D} #{C5B6} #{C39F} #{C3A0} #{C3A1} #{C3A2} #{C3A3}
 #{C3A4} #{C3A5} #{C3A6} #{C3A7} #{C3A8} #{C3A9} #{C3AA} #{C3AB}
 #{C3AC} #{C3AD} #{C3AE} #{C3AF} #{C5B5} #{C3B1} #{C3B2} #{C3B3}
 #{C3B4} #{C3B5} #{C3B6} #{E1B9AB} #{C3B8} #{C3B9} #{C3BA} #{C3BB}
 #{C3BC} #{C3BD} #{C5B7} #{C3BF}
]
iso-8859-15: make-encoding [
 #{00} #{01} #{02} #{03} #{04} #{05} #{06} #{07} #{08} #{09} #{0A}
 #{0B} #{0C} #{0D} #{0E} #{0F} #{10} #{11} #{12} #{13} #{14} #{15}
 #{16} #{17} #{18} #{19} #{1A} #{1B} #{1C} #{1D} #{1E} #{1F} #{20}
 #{21} #{22} #{23} #{24} #{25} #{26} #{27} #{28} #{29} #{2A} #{2B}
 #{2C} #{2D} #{2E} #{2F} #{30} #{31} #{32} #{33} #{34} #{35} #{36}
 #{37} #{38} #{39} #{3A} #{3B} #{3C} #{3D} #{3E} #{3F} #{40} #{41}
 #{42} #{43} #{44} #{45} #{46} #{47} #{48} #{49} #{4A} #{4B} #{4C}
 #{4D} #{4E} #{4F} #{50} #{51} #{52} #{53} #{54} #{55} #{56} #{57}
 #{58} #{59} #{5A} #{5B} #{5C} #{5D} #{5E} #{5F} #{60} #{61} #{62}
 #{63} #{64} #{65} #{66} #{67} #{68} #{69} #{6A} #{6B} #{6C} #{6D}
 #{6E} #{6F} #{70} #{71} #{72} #{73} #{74} #{75} #{76} #{77} #{78}
 #{79} #{7A} #{7B} #{7C} #{7D} #{7E} #{7F} #{C280} #{C281} #{C282}
 #{C283} #{C284} #{C285} #{C286} #{C287} #{C288} #{C289} #{C28A}
 #{C28B} #{C28C} #{C28D} #{C28E} #{C28F} #{C290} #{C291} #{C292}
 #{C293} #{C294} #{C295} #{C296} #{C297} #{C298} #{C299} #{C29A}
 #{C29B} #{C29C} #{C29D} #{C29E} #{C29F} #{C2A0} #{C2A1} #{C2A2}
 #{C2A3} #{E282AC} #{C2A5} #{C5A0} #{C2A7} #{C5A1} #{C2A9} #{C2AA}
 #{C2AB} #{C2AC} #{C2AD} #{C2AE} #{C2AF} #{C2B0} #{C2B1} #{C2B2}
 #{C2B3} #{C5BD} #{C2B5} #{C2B6} #{C2B7} #{C5BE} #{C2B9} #{C2BA}
 #{C2BB} #{C592} #{C593} #{C5B8} #{C2BF} #{C380} #{C381} #{C382}
 #{C383} #{C384} #{C385} #{C386} #{C387} #{C388} #{C389} #{C38A}
 #{C38B} #{C38C} #{C38D} #{C38E} #{C38F} #{C390} #{C391} #{C392}
 #{C393} #{C394} #{C395} #{C396} #{C397} #{C398} #{C399} #{C39A}
 #{C39B} #{C39C} #{C39D} #{C39E} #{C39F} #{C3A0} #{C3A1} #{C3A2}
 #{C3A3} #{C3A4} #{C3A5} #{C3A6} #{C3A7} #{C3A8} #{C3A9} #{C3AA}
 #{C3AB} #{C3AC} #{C3AD} #{C3AE} #{C3AF} #{C3B0} #{C3B1} #{C3B2}
 #{C3B3} #{C3B4} #{C3B5} #{C3B6} #{C3B7} #{C3B8} #{C3B9} #{C3BA}
 #{C3BB} #{C3BC} #{C3BD} #{C3BE} #{C3BF}
]
iso-8859-16: latin10: make-encoding [
 #{00} #{01} #{02} #{03} #{04} #{05} #{06} #{07} #{08} #{09} #{0A}
 #{0B} #{0C} #{0D} #{0E} #{0F} #{10} #{11} #{12} #{13} #{14} #{15}
 #{16} #{17} #{18} #{19} #{1A} #{1B} #{1C} #{1D} #{1E} #{1F} #{20}
 #{21} #{22} #{23} #{24} #{25} #{26} #{27} #{28} #{29} #{2A} #{2B}
 #{2C} #{2D} #{2E} #{2F} #{30} #{31} #{32} #{33} #{34} #{35} #{36}
 #{37} #{38} #{39} #{3A} #{3B} #{3C} #{3D} #{3E} #{3F} #{40} #{41}
 #{42} #{43} #{44} #{45} #{46} #{47} #{48} #{49} #{4A} #{4B} #{4C}
 #{4D} #{4E} #{4F} #{50} #{51} #{52} #{53} #{54} #{55} #{56} #{57}
 #{58} #{59} #{5A} #{5B} #{5C} #{5D} #{5E} #{5F} #{60} #{61} #{62}
 #{63} #{64} #{65} #{66} #{67} #{68} #{69} #{6A} #{6B} #{6C} #{6D}
 #{6E} #{6F} #{70} #{71} #{72} #{73} #{74} #{75} #{76} #{77} #{78}
 #{79} #{7A} #{7B} #{7C} #{7D} #{7E} #{7F} #{C280} #{C281} #{C282}
 #{C283} #{C284} #{C285} #{C286} #{C287} #{C288} #{C289} #{C28A}
 #{C28B} #{C28C} #{C28D} #{C28E} #{C28F} #{C290} #{C291} #{C292}
 #{C293} #{C294} #{C295} #{C296} #{C297} #{C298} #{C299} #{C29A}
 #{C29B} #{C29C} #{C29D} #{C29E} #{C29F} #{C2A0} #{C484} #{C485}
 #{C581} #{E282AC} #{E2809E} #{C5A0} #{C2A7} #{C5A1} #{C2A9}
 #{C898} #{C2AB} #{C5B9} #{C2AD} #{C5BA} #{C5BB} #{C2B0} #{C2B1}
 #{C48C} #{C582} #{C5BD} #{E2809D} #{C2B6} #{C2B7} #{C5BE} #{C48D}
 #{C899} #{C2BB} #{C592} #{C593} #{C5B8} #{C5BC} #{C380} #{C381}
 #{C382} #{C482} #{C384} #{C486} #{C386} #{C387} #{C388} #{C389}
 #{C38A} #{C38B} #{C38C} #{C38D} #{C38E} #{C38F} #{C490} #{C583}
 #{C392} #{C393} #{C394} #{C590} #{C396} #{C59A} #{C5B0} #{C399}
 #{C39A} #{C39B} #{C39C} #{C498} #{C89A} #{C39F} #{C3A0} #{C3A1}
 #{C3A2} #{C483} #{C3A4} #{C487} #{C3A6} #{C3A7} #{C3A8} #{C3A9}
 #{C3AA} #{C3AB} #{C3AC} #{C3AD} #{C3AE} #{C3AF} #{C491} #{C584}
 #{C3B2} #{C3B3} #{C3B4} #{C591} #{C3B6} #{C59B} #{C5B1} #{C3B9}
 #{C3BA} #{C3BB} #{C3BC} #{C499} #{C89B} #{C3BF}
]

The windows-1252 encoding is Microsoft's variant of latin1 (because they could not obviously use a standard).

List of supported encodings +≡

windows-1252: make-encoding [
 #{00} #{01} #{02} #{03} #{04} #{05} #{06} #{07} #{08} #{09} #{0A}
 #{0B} #{0C} #{0D} #{0E} #{0F} #{10} #{11} #{12} #{13} #{14} #{15}
 #{16} #{17} #{18} #{19} #{1A} #{1B} #{1C} #{1D} #{1E} #{1F} #{20}
 #{21} #{22} #{23} #{24} #{25} #{26} #{27} #{28} #{29} #{2A} #{2B}
 #{2C} #{2D} #{2E} #{2F} #{30} #{31} #{32} #{33} #{34} #{35} #{36}
 #{37} #{38} #{39} #{3A} #{3B} #{3C} #{3D} #{3E} #{3F} #{40} #{41}
 #{42} #{43} #{44} #{45} #{46} #{47} #{48} #{49} #{4A} #{4B} #{4C}
 #{4D} #{4E} #{4F} #{50} #{51} #{52} #{53} #{54} #{55} #{56} #{57}
 #{58} #{59} #{5A} #{5B} #{5C} #{5D} #{5E} #{5F} #{60} #{61} #{62}
 #{63} #{64} #{65} #{66} #{67} #{68} #{69} #{6A} #{6B} #{6C} #{6D}
 #{6E} #{6F} #{70} #{71} #{72} #{73} #{74} #{75} #{76} #{77} #{78}
 #{79} #{7A} #{7B} #{7C} #{7D} #{7E} #{7F} #{E282AC} #{3F}
 #{E2809A} #{C692} #{E2809E} #{E280A6} #{E280A0} #{E280A1} #{CB86}
 #{E280B0} #{C5A0} #{E280B9} #{C592} #{3F} #{C5BD} #{3F} #{3F}
 #{E28098} #{E28099} #{E2809C} #{E2809D} #{E280A2} #{E28093}
 #{E28094} #{CB9C} #{E284A2} #{C5A1} #{E280BA} #{C593} #{3F}
 #{C5BE} #{C5B8} #{C2A0} #{C2A1} #{C2A2} #{C2A3} #{C2A4} #{C2A5}
 #{C2A6} #{C2A7} #{C2A8} #{C2A9} #{C2AA} #{C2AB} #{C2AC} #{C2AD}
 #{C2AE} #{C2AF} #{C2B0} #{C2B1} #{C2B2} #{C2B3} #{C2B4} #{C2B5}
 #{C2B6} #{C2B7} #{C2B8} #{C2B9} #{C2BA} #{C2BB} #{C2BC} #{C2BD}
 #{C2BE} #{C2BF} #{C380} #{C381} #{C382} #{C383} #{C384} #{C385}
 #{C386} #{C387} #{C388} #{C389} #{C38A} #{C38B} #{C38C} #{C38D}
 #{C38E} #{C38F} #{C390} #{C391} #{C392} #{C393} #{C394} #{C395}
 #{C396} #{C397} #{C398} #{C399} #{C39A} #{C39B} #{C39C} #{C39D}
 #{C39E} #{C39F} #{C3A0} #{C3A1} #{C3A2} #{C3A3} #{C3A4} #{C3A5}
 #{C3A6} #{C3A7} #{C3A8} #{C3A9} #{C3AA} #{C3AB} #{C3AC} #{C3AD}
 #{C3AE} #{C3AF} #{C3B0} #{C3B1} #{C3B2} #{C3B3} #{C3B4} #{C3B5}
 #{C3B6} #{C3B7} #{C3B8} #{C3B9} #{C3BA} #{C3BB} #{C3BC} #{C3BD}
 #{C3BE} #{C3BF}
]

Other Microsoft custom encodings follow:

List of supported encodings +≡

windows-1250: make-encoding [
 #{00} #{01} #{02} #{03} #{04} #{05} #{06} #{07} #{08} #{09} #{0A}
 #{0B} #{0C} #{0D} #{0E} #{0F} #{10} #{11} #{12} #{13} #{14} #{15}
 #{16} #{17} #{18} #{19} #{1A} #{1B} #{1C} #{1D} #{1E} #{1F} #{20}
 #{21} #{22} #{23} #{24} #{25} #{26} #{27} #{28} #{29} #{2A} #{2B}
 #{2C} #{2D} #{2E} #{2F} #{30} #{31} #{32} #{33} #{34} #{35} #{36}
 #{37} #{38} #{39} #{3A} #{3B} #{3C} #{3D} #{3E} #{3F} #{40} #{41}
 #{42} #{43} #{44} #{45} #{46} #{47} #{48} #{49} #{4A} #{4B} #{4C}
 #{4D} #{4E} #{4F} #{50} #{51} #{52} #{53} #{54} #{55} #{56} #{57}
 #{58} #{59} #{5A} #{5B} #{5C} #{5D} #{5E} #{5F} #{60} #{61} #{62}
 #{63} #{64} #{65} #{66} #{67} #{68} #{69} #{6A} #{6B} #{6C} #{6D}
 #{6E} #{6F} #{70} #{71} #{72} #{73} #{74} #{75} #{76} #{77} #{78}
 #{79} #{7A} #{7B} #{7C} #{7D} #{7E} #{7F} #{E282AC} #{3F}
 #{E2809A} #{3F} #{E2809E} #{E280A6} #{E280A0} #{E280A1} #{3F}
 #{E280B0} #{C5A0} #{E280B9} #{C59A} #{C5A4} #{C5BD} #{C5B9} #{3F}
 #{E28098} #{E28099} #{E2809C} #{E2809D} #{E280A2} #{E28093}
 #{E28094} #{3F} #{E284A2} #{C5A1} #{E280BA} #{C59B} #{C5A5}
 #{C5BE} #{C5BA} #{C2A0} #{CB87} #{CB98} #{C581} #{C2A4} #{C484}
 #{C2A6} #{C2A7} #{C2A8} #{C2A9} #{C59E} #{C2AB} #{C2AC} #{C2AD}
 #{C2AE} #{C5BB} #{C2B0} #{C2B1} #{CB9B} #{C582} #{C2B4} #{C2B5}
 #{C2B6} #{C2B7} #{C2B8} #{C485} #{C59F} #{C2BB} #{C4BD} #{CB9D}
 #{C4BE} #{C5BC} #{C594} #{C381} #{C382} #{C482} #{C384} #{C4B9}
 #{C486} #{C387} #{C48C} #{C389} #{C498} #{C38B} #{C49A} #{C38D}
 #{C38E} #{C48E} #{C490} #{C583} #{C587} #{C393} #{C394} #{C590}
 #{C396} #{C397} #{C598} #{C5AE} #{C39A} #{C5B0} #{C39C} #{C39D}
 #{C5A2} #{C39F} #{C595} #{C3A1} #{C3A2} #{C483} #{C3A4} #{C4BA}
 #{C487} #{C3A7} #{C48D} #{C3A9} #{C499} #{C3AB} #{C49B} #{C3AD}
 #{C3AE} #{C48F} #{C491} #{C584} #{C588} #{C3B3} #{C3B4} #{C591}
 #{C3B6} #{C3B7} #{C599} #{C5AF} #{C3BA} #{C5B1} #{C3BC} #{C3BD}
 #{C5A3} #{CB99}
]
windows-874: make-encoding [
 #{00} #{01} #{02} #{03} #{04} #{05} #{06} #{07} #{08} #{09} #{0A}
 #{0B} #{0C} #{0D} #{0E} #{0F} #{10} #{11} #{12} #{13} #{14} #{15}
 #{16} #{17} #{18} #{19} #{1A} #{1B} #{1C} #{1D} #{1E} #{1F} #{20}
 #{21} #{22} #{23} #{24} #{25} #{26} #{27} #{28} #{29} #{2A} #{2B}
 #{2C} #{2D} #{2E} #{2F} #{30} #{31} #{32} #{33} #{34} #{35} #{36}
 #{37} #{38} #{39} #{3A} #{3B} #{3C} #{3D} #{3E} #{3F} #{40} #{41}
 #{42} #{43} #{44} #{45} #{46} #{47} #{48} #{49} #{4A} #{4B} #{4C}
 #{4D} #{4E} #{4F} #{50} #{51} #{52} #{53} #{54} #{55} #{56} #{57}
 #{58} #{59} #{5A} #{5B} #{5C} #{5D} #{5E} #{5F} #{60} #{61} #{62}
 #{63} #{64} #{65} #{66} #{67} #{68} #{69} #{6A} #{6B} #{6C} #{6D}
 #{6E} #{6F} #{70} #{71} #{72} #{73} #{74} #{75} #{76} #{77} #{78}
 #{79} #{7A} #{7B} #{7C} #{7D} #{7E} #{7F} #{E282AC} #{3F} #{3F}
 #{3F} #{3F} #{E280A6} #{3F} #{3F} #{3F} #{3F} #{3F} #{3F} #{3F}
 #{3F} #{3F} #{3F} #{3F} #{E28098} #{E28099} #{E2809C} #{E2809D}
 #{E280A2} #{E28093} #{E28094} #{3F} #{3F} #{3F} #{3F} #{3F} #{3F}
 #{3F} #{3F} #{C2A0} #{E0B881} #{E0B882} #{E0B883} #{E0B884}
 #{E0B885} #{E0B886} #{E0B887} #{E0B888} #{E0B889} #{E0B88A}
 #{E0B88B} #{E0B88C} #{E0B88D} #{E0B88E} #{E0B88F} #{E0B890}
 #{E0B891} #{E0B892} #{E0B893} #{E0B894} #{E0B895} #{E0B896}
 #{E0B897} #{E0B898} #{E0B899} #{E0B89A} #{E0B89B} #{E0B89C}
 #{E0B89D} #{E0B89E} #{E0B89F} #{E0B8A0} #{E0B8A1} #{E0B8A2}
 #{E0B8A3} #{E0B8A4} #{E0B8A5} #{E0B8A6} #{E0B8A7} #{E0B8A8}
 #{E0B8A9} #{E0B8AA} #{E0B8AB} #{E0B8AC} #{E0B8AD} #{E0B8AE}
 #{E0B8AF} #{E0B8B0} #{E0B8B1} #{E0B8B2} #{E0B8B3} #{E0B8B4}
 #{E0B8B5} #{E0B8B6} #{E0B8B7} #{E0B8B8} #{E0B8B9} #{E0B8BA} #{3F}
 #{3F} #{3F} #{3F} #{E0B8BF} #{E0B980} #{E0B981} #{E0B982}
 #{E0B983} #{E0B984} #{E0B985} #{E0B986} #{E0B987} #{E0B988}
 #{E0B989} #{E0B98A} #{E0B98B} #{E0B98C} #{E0B98D} #{E0B98E}
 #{E0B98F} #{E0B990} #{E0B991} #{E0B992} #{E0B993} #{E0B994}
 #{E0B995} #{E0B996} #{E0B997} #{E0B998} #{E0B999} #{E0B99A}
 #{E0B99B} #{3F} #{3F} #{3F} #{3F}
]
windows-1251: make-encoding [
 #{00} #{01} #{02} #{03} #{04} #{05} #{06} #{07} #{08} #{09} #{0A}
 #{0B} #{0C} #{0D} #{0E} #{0F} #{10} #{11} #{12} #{13} #{14} #{15}
 #{16} #{17} #{18} #{19} #{1A} #{1B} #{1C} #{1D} #{1E} #{1F} #{20}
 #{21} #{22} #{23} #{24} #{25} #{26} #{27} #{28} #{29} #{2A} #{2B}
 #{2C} #{2D} #{2E} #{2F} #{30} #{31} #{32} #{33} #{34} #{35} #{36}
 #{37} #{38} #{39} #{3A} #{3B} #{3C} #{3D} #{3E} #{3F} #{40} #{41}
 #{42} #{43} #{44} #{45} #{46} #{47} #{48} #{49} #{4A} #{4B} #{4C}
 #{4D} #{4E} #{4F} #{50} #{51} #{52} #{53} #{54} #{55} #{56} #{57}
 #{58} #{59} #{5A} #{5B} #{5C} #{5D} #{5E} #{5F} #{60} #{61} #{62}
 #{63} #{64} #{65} #{66} #{67} #{68} #{69} #{6A} #{6B} #{6C} #{6D}
 #{6E} #{6F} #{70} #{71} #{72} #{73} #{74} #{75} #{76} #{77} #{78}
 #{79} #{7A} #{7B} #{7C} #{7D} #{7E} #{7F} #{D082} #{D083}
 #{E2809A} #{D193} #{E2809E} #{E280A6} #{E280A0} #{E280A1}
 #{E282AC} #{E280B0} #{D089} #{E280B9} #{D08A} #{D08C} #{D08B}
 #{D08F} #{D192} #{E28098} #{E28099} #{E2809C} #{E2809D} #{E280A2}
 #{E28093} #{E28094} #{3F} #{E284A2} #{D199} #{E280BA} #{D19A}
 #{D19C} #{D19B} #{D19F} #{C2A0} #{D08E} #{D19E} #{D088} #{C2A4}
 #{D290} #{C2A6} #{C2A7} #{D081} #{C2A9} #{D084} #{C2AB} #{C2AC}
 #{C2AD} #{C2AE} #{D087} #{C2B0} #{C2B1} #{D086} #{D196} #{D291}
 #{C2B5} #{C2B6} #{C2B7} #{D191} #{E28496} #{D194} #{C2BB} #{D198}
 #{D085} #{D195} #{D197} #{D090} #{D091} #{D092} #{D093} #{D094}
 #{D095} #{D096} #{D097} #{D098} #{D099} #{D09A} #{D09B} #{D09C}
 #{D09D} #{D09E} #{D09F} #{D0A0} #{D0A1} #{D0A2} #{D0A3} #{D0A4}
 #{D0A5} #{D0A6} #{D0A7} #{D0A8} #{D0A9} #{D0AA} #{D0AB} #{D0AC}
 #{D0AD} #{D0AE} #{D0AF} #{D0B0} #{D0B1} #{D0B2} #{D0B3} #{D0B4}
 #{D0B5} #{D0B6} #{D0B7} #{D0B8} #{D0B9} #{D0BA} #{D0BB} #{D0BC}
 #{D0BD} #{D0BE} #{D0BF} #{D180} #{D181} #{D182} #{D183} #{D184}
 #{D185} #{D186} #{D187} #{D188} #{D189} #{D18A} #{D18B} #{D18C}
 #{D18D} #{D18E} #{D18F}
]
windows-1253: make-encoding [
 #{00} #{01} #{02} #{03} #{04} #{05} #{06} #{07} #{08} #{09} #{0A}
 #{0B} #{0C} #{0D} #{0E} #{0F} #{10} #{11} #{12} #{13} #{14} #{15}
 #{16} #{17} #{18} #{19} #{1A} #{1B} #{1C} #{1D} #{1E} #{1F} #{20}
 #{21} #{22} #{23} #{24} #{25} #{26} #{27} #{28} #{29} #{2A} #{2B}
 #{2C} #{2D} #{2E} #{2F} #{30} #{31} #{32} #{33} #{34} #{35} #{36}
 #{37} #{38} #{39} #{3A} #{3B} #{3C} #{3D} #{3E} #{3F} #{40} #{41}
 #{42} #{43} #{44} #{45} #{46} #{47} #{48} #{49} #{4A} #{4B} #{4C}
 #{4D} #{4E} #{4F} #{50} #{51} #{52} #{53} #{54} #{55} #{56} #{57}
 #{58} #{59} #{5A} #{5B} #{5C} #{5D} #{5E} #{5F} #{60} #{61} #{62}
 #{63} #{64} #{65} #{66} #{67} #{68} #{69} #{6A} #{6B} #{6C} #{6D}
 #{6E} #{6F} #{70} #{71} #{72} #{73} #{74} #{75} #{76} #{77} #{78}
 #{79} #{7A} #{7B} #{7C} #{7D} #{7E} #{7F} #{E282AC} #{3F}
 #{E2809A} #{C692} #{E2809E} #{E280A6} #{E280A0} #{E280A1} #{3F}
 #{E280B0} #{3F} #{E280B9} #{3F} #{3F} #{3F} #{3F} #{3F} #{E28098}
 #{E28099} #{E2809C} #{E2809D} #{E280A2} #{E28093} #{E28094} #{3F}
 #{E284A2} #{3F} #{E280BA} #{3F} #{3F} #{3F} #{3F} #{C2A0} #{CE85}
 #{CE86} #{C2A3} #{C2A4} #{C2A5} #{C2A6} #{C2A7} #{C2A8} #{C2A9}
 #{3F} #{C2AB} #{C2AC} #{C2AD} #{C2AE} #{E28095} #{C2B0} #{C2B1}
 #{C2B2} #{C2B3} #{CE84} #{C2B5} #{C2B6} #{C2B7} #{CE88} #{CE89}
 #{CE8A} #{C2BB} #{CE8C} #{C2BD} #{CE8E} #{CE8F} #{CE90} #{CE91}
 #{CE92} #{CE93} #{CE94} #{CE95} #{CE96} #{CE97} #{CE98} #{CE99}
 #{CE9A} #{CE9B} #{CE9C} #{CE9D} #{CE9E} #{CE9F} #{CEA0} #{CEA1}
 #{3F} #{CEA3} #{CEA4} #{CEA5} #{CEA6} #{CEA7} #{CEA8} #{CEA9}
 #{CEAA} #{CEAB} #{CEAC} #{CEAD} #{CEAE} #{CEAF} #{CEB0} #{CEB1}
 #{CEB2} #{CEB3} #{CEB4} #{CEB5} #{CEB6} #{CEB7} #{CEB8} #{CEB9}
 #{CEBA} #{CEBB} #{CEBC} #{CEBD} #{CEBE} #{CEBF} #{CF80} #{CF81}
 #{CF82} #{CF83} #{CF84} #{CF85} #{CF86} #{CF87} #{CF88} #{CF89}
 #{CF8A} #{CF8B} #{CF8C} #{CF8D} #{CF8E} #{3F}
]
windows-1254: make-encoding [
 #{00} #{01} #{02} #{03} #{04} #{05} #{06} #{07} #{08} #{09} #{0A}
 #{0B} #{0C} #{0D} #{0E} #{0F} #{10} #{11} #{12} #{13} #{14} #{15}
 #{16} #{17} #{18} #{19} #{1A} #{1B} #{1C} #{1D} #{1E} #{1F} #{20}
 #{21} #{22} #{23} #{24} #{25} #{26} #{27} #{28} #{29} #{2A} #{2B}
 #{2C} #{2D} #{2E} #{2F} #{30} #{31} #{32} #{33} #{34} #{35} #{36}
 #{37} #{38} #{39} #{3A} #{3B} #{3C} #{3D} #{3E} #{3F} #{40} #{41}
 #{42} #{43} #{44} #{45} #{46} #{47} #{48} #{49} #{4A} #{4B} #{4C}
 #{4D} #{4E} #{4F} #{50} #{51} #{52} #{53} #{54} #{55} #{56} #{57}
 #{58} #{59} #{5A} #{5B} #{5C} #{5D} #{5E} #{5F} #{60} #{61} #{62}
 #{63} #{64} #{65} #{66} #{67} #{68} #{69} #{6A} #{6B} #{6C} #{6D}
 #{6E} #{6F} #{70} #{71} #{72} #{73} #{74} #{75} #{76} #{77} #{78}
 #{79} #{7A} #{7B} #{7C} #{7D} #{7E} #{7F} #{E282AC} #{3F}
 #{E2809A} #{C692} #{E2809E} #{E280A6} #{E280A0} #{E280A1} #{CB86}
 #{E280B0} #{C5A0} #{E280B9} #{C592} #{3F} #{3F} #{3F} #{3F}
 #{E28098} #{E28099} #{E2809C} #{E2809D} #{E280A2} #{E28093}
 #{E28094} #{CB9C} #{E284A2} #{C5A1} #{E280BA} #{C593} #{3F} #{3F}
 #{C5B8} #{C2A0} #{C2A1} #{C2A2} #{C2A3} #{C2A4} #{C2A5} #{C2A6}
 #{C2A7} #{C2A8} #{C2A9} #{C2AA} #{C2AB} #{C2AC} #{C2AD} #{C2AE}
 #{C2AF} #{C2B0} #{C2B1} #{C2B2} #{C2B3} #{C2B4} #{C2B5} #{C2B6}
 #{C2B7} #{C2B8} #{C2B9} #{C2BA} #{C2BB} #{C2BC} #{C2BD} #{C2BE}
 #{C2BF} #{C380} #{C381} #{C382} #{C383} #{C384} #{C385} #{C386}
 #{C387} #{C388} #{C389} #{C38A} #{C38B} #{C38C} #{C38D} #{C38E}
 #{C38F} #{C49E} #{C391} #{C392} #{C393} #{C394} #{C395} #{C396}
 #{C397} #{C398} #{C399} #{C39A} #{C39B} #{C39C} #{C4B0} #{C59E}
 #{C39F} #{C3A0} #{C3A1} #{C3A2} #{C3A3} #{C3A4} #{C3A5} #{C3A6}
 #{C3A7} #{C3A8} #{C3A9} #{C3AA} #{C3AB} #{C3AC} #{C3AD} #{C3AE}
 #{C3AF} #{C49F} #{C3B1} #{C3B2} #{C3B3} #{C3B4} #{C3B5} #{C3B6}
 #{C3B7} #{C3B8} #{C3B9} #{C3BA} #{C3BB} #{C3BC} #{C4B1} #{C59F}
 #{C3BF}
]
windows-1255: make-encoding [
 #{00} #{01} #{02} #{03} #{04} #{05} #{06} #{07} #{08} #{09} #{0A}
 #{0B} #{0C} #{0D} #{0E} #{0F} #{10} #{11} #{12} #{13} #{14} #{15}
 #{16} #{17} #{18} #{19} #{1A} #{1B} #{1C} #{1D} #{1E} #{1F} #{20}
 #{21} #{22} #{23} #{24} #{25} #{26} #{27} #{28} #{29} #{2A} #{2B}
 #{2C} #{2D} #{2E} #{2F} #{30} #{31} #{32} #{33} #{34} #{35} #{36}
 #{37} #{38} #{39} #{3A} #{3B} #{3C} #{3D} #{3E} #{3F} #{40} #{41}
 #{42} #{43} #{44} #{45} #{46} #{47} #{48} #{49} #{4A} #{4B} #{4C}
 #{4D} #{4E} #{4F} #{50} #{51} #{52} #{53} #{54} #{55} #{56} #{57}
 #{58} #{59} #{5A} #{5B} #{5C} #{5D} #{5E} #{5F} #{60} #{61} #{62}
 #{63} #{64} #{65} #{66} #{67} #{68} #{69} #{6A} #{6B} #{6C} #{6D}
 #{6E} #{6F} #{70} #{71} #{72} #{73} #{74} #{75} #{76} #{77} #{78}
 #{79} #{7A} #{7B} #{7C} #{7D} #{7E} #{7F} #{E282AC} #{3F}
 #{E2809A} #{C692} #{E2809E} #{E280A6} #{E280A0} #{E280A1} #{CB86}
 #{E280B0} #{3F} #{E280B9} #{3F} #{3F} #{3F} #{3F} #{3F} #{E28098}
 #{E28099} #{E2809C} #{E2809D} #{E280A2} #{E28093} #{E28094}
 #{CB9C} #{E284A2} #{3F} #{E280BA} #{3F} #{3F} #{3F} #{3F} #{C2A0}
 #{C2A1} #{C2A2} #{C2A3} #{E282AA} #{C2A5} #{C2A6} #{C2A7} #{C2A8}
 #{C2A9} #{C397} #{C2AB} #{C2AC} #{C2AD} #{C2AE} #{C2AF} #{C2B0}
 #{C2B1} #{C2B2} #{C2B3} #{C2B4} #{C2B5} #{C2B6} #{C2B7} #{C2B8}
 #{C2B9} #{C3B7} #{C2BB} #{C2BC} #{C2BD} #{C2BE} #{C2BF} #{D6B0}
 #{D6B1} #{D6B2} #{D6B3} #{D6B4} #{D6B5} #{D6B6} #{D6B7} #{D6B8}
 #{D6B9} #{3F} #{D6BB} #{D6BC} #{D6BD} #{D6BE} #{D6BF} #{D780}
 #{D781} #{D782} #{D783} #{D7B0} #{D7B1} #{D7B2} #{D7B3} #{D7B4}
 #{3F} #{3F} #{3F} #{3F} #{3F} #{3F} #{3F} #{D790} #{D791} #{D792}
 #{D793} #{D794} #{D795} #{D796} #{D797} #{D798} #{D799} #{D79A}
 #{D79B} #{D79C} #{D79D} #{D79E} #{D79F} #{D7A0} #{D7A1} #{D7A2}
 #{D7A3} #{D7A4} #{D7A5} #{D7A6} #{D7A7} #{D7A8} #{D7A9} #{D7AA}
 #{3F} #{3F} #{E2808E} #{E2808F} #{3F}
]
windows-1256: make-encoding [
 #{00} #{01} #{02} #{03} #{04} #{05} #{06} #{07} #{08} #{09} #{0A}
 #{0B} #{0C} #{0D} #{0E} #{0F} #{10} #{11} #{12} #{13} #{14} #{15}
 #{16} #{17} #{18} #{19} #{1A} #{1B} #{1C} #{1D} #{1E} #{1F} #{20}
 #{21} #{22} #{23} #{24} #{25} #{26} #{27} #{28} #{29} #{2A} #{2B}
 #{2C} #{2D} #{2E} #{2F} #{30} #{31} #{32} #{33} #{34} #{35} #{36}
 #{37} #{38} #{39} #{3A} #{3B} #{3C} #{3D} #{3E} #{3F} #{40} #{41}
 #{42} #{43} #{44} #{45} #{46} #{47} #{48} #{49} #{4A} #{4B} #{4C}
 #{4D} #{4E} #{4F} #{50} #{51} #{52} #{53} #{54} #{55} #{56} #{57}
 #{58} #{59} #{5A} #{5B} #{5C} #{5D} #{5E} #{5F} #{60} #{61} #{62}
 #{63} #{64} #{65} #{66} #{67} #{68} #{69} #{6A} #{6B} #{6C} #{6D}
 #{6E} #{6F} #{70} #{71} #{72} #{73} #{74} #{75} #{76} #{77} #{78}
 #{79} #{7A} #{7B} #{7C} #{7D} #{7E} #{7F} #{E282AC} #{D9BE}
 #{E2809A} #{C692} #{E2809E} #{E280A6} #{E280A0} #{E280A1} #{CB86}
 #{E280B0} #{D9B9} #{E280B9} #{C592} #{DA86} #{DA98} #{DA88}
 #{DAAF} #{E28098} #{E28099} #{E2809C} #{E2809D} #{E280A2}
 #{E28093} #{E28094} #{DAA9} #{E284A2} #{DA91} #{E280BA} #{C593}
 #{E2808C} #{E2808D} #{DABA} #{C2A0} #{D88C} #{C2A2} #{C2A3}
 #{C2A4} #{C2A5} #{C2A6} #{C2A7} #{C2A8} #{C2A9} #{DABE} #{C2AB}
 #{C2AC} #{C2AD} #{C2AE} #{C2AF} #{C2B0} #{C2B1} #{C2B2} #{C2B3}
 #{C2B4} #{C2B5} #{C2B6} #{C2B7} #{C2B8} #{C2B9} #{D89B} #{C2BB}
 #{C2BC} #{C2BD} #{C2BE} #{D89F} #{DB81} #{D8A1} #{D8A2} #{D8A3}
 #{D8A4} #{D8A5} #{D8A6} #{D8A7} #{D8A8} #{D8A9} #{D8AA} #{D8AB}
 #{D8AC} #{D8AD} #{D8AE} #{D8AF} #{D8B0} #{D8B1} #{D8B2} #{D8B3}
 #{D8B4} #{D8B5} #{D8B6} #{C397} #{D8B7} #{D8B8} #{D8B9} #{D8BA}
 #{D980} #{D981} #{D982} #{D983} #{C3A0} #{D984} #{C3A2} #{D985}
 #{D986} #{D987} #{D988} #{C3A7} #{C3A8} #{C3A9} #{C3AA} #{C3AB}
 #{D989} #{D98A} #{C3AE} #{C3AF} #{D98B} #{D98C} #{D98D} #{D98E}
 #{C3B4} #{D98F} #{D990} #{C3B7} #{D991} #{C3B9} #{D992} #{C3BB}
 #{C3BC} #{E2808E} #{E2808F} #{DB92}
]
windows-1257: make-encoding [
 #{00} #{01} #{02} #{03} #{04} #{05} #{06} #{07} #{08} #{09} #{0A}
 #{0B} #{0C} #{0D} #{0E} #{0F} #{10} #{11} #{12} #{13} #{14} #{15}
 #{16} #{17} #{18} #{19} #{1A} #{1B} #{1C} #{1D} #{1E} #{1F} #{20}
 #{21} #{22} #{23} #{24} #{25} #{26} #{27} #{28} #{29} #{2A} #{2B}
 #{2C} #{2D} #{2E} #{2F} #{30} #{31} #{32} #{33} #{34} #{35} #{36}
 #{37} #{38} #{39} #{3A} #{3B} #{3C} #{3D} #{3E} #{3F} #{40} #{41}
 #{42} #{43} #{44} #{45} #{46} #{47} #{48} #{49} #{4A} #{4B} #{4C}
 #{4D} #{4E} #{4F} #{50} #{51} #{52} #{53} #{54} #{55} #{56} #{57}
 #{58} #{59} #{5A} #{5B} #{5C} #{5D} #{5E} #{5F} #{60} #{61} #{62}
 #{63} #{64} #{65} #{66} #{67} #{68} #{69} #{6A} #{6B} #{6C} #{6D}
 #{6E} #{6F} #{70} #{71} #{72} #{73} #{74} #{75} #{76} #{77} #{78}
 #{79} #{7A} #{7B} #{7C} #{7D} #{7E} #{7F} #{E282AC} #{3F}
 #{E2809A} #{3F} #{E2809E} #{E280A6} #{E280A0} #{E280A1} #{3F}
 #{E280B0} #{3F} #{E280B9} #{3F} #{C2A8} #{CB87} #{C2B8} #{3F}
 #{E28098} #{E28099} #{E2809C} #{E2809D} #{E280A2} #{E28093}
 #{E28094} #{3F} #{E284A2} #{3F} #{E280BA} #{3F} #{C2AF} #{CB9B}
 #{3F} #{C2A0} #{3F} #{C2A2} #{C2A3} #{C2A4} #{3F} #{C2A6} #{C2A7}
 #{C398} #{C2A9} #{C596} #{C2AB} #{C2AC} #{C2AD} #{C2AE} #{C386}
 #{C2B0} #{C2B1} #{C2B2} #{C2B3} #{C2B4} #{C2B5} #{C2B6} #{C2B7}
 #{C3B8} #{C2B9} #{C597} #{C2BB} #{C2BC} #{C2BD} #{C2BE} #{C3A6}
 #{C484} #{C4AE} #{C480} #{C486} #{C384} #{C385} #{C498} #{C492}
 #{C48C} #{C389} #{C5B9} #{C496} #{C4A2} #{C4B6} #{C4AA} #{C4BB}
 #{C5A0} #{C583} #{C585} #{C393} #{C58C} #{C395} #{C396} #{C397}
 #{C5B2} #{C581} #{C59A} #{C5AA} #{C39C} #{C5BB} #{C5BD} #{C39F}
 #{C485} #{C4AF} #{C481} #{C487} #{C3A4} #{C3A5} #{C499} #{C493}
 #{C48D} #{C3A9} #{C5BA} #{C497} #{C4A3} #{C4B7} #{C4AB} #{C4BC}
 #{C5A1} #{C584} #{C586} #{C3B3} #{C58D} #{C3B5} #{C3B6} #{C3B7}
 #{C5B3} #{C582} #{C59B} #{C5AB} #{C3BC} #{C5BC} #{C5BE} #{CB99}
]
windows-1258: make-encoding [
 #{00} #{01} #{02} #{03} #{04} #{05} #{06} #{07} #{08} #{09} #{0A}
 #{0B} #{0C} #{0D} #{0E} #{0F} #{10} #{11} #{12} #{13} #{14} #{15}
 #{16} #{17} #{18} #{19} #{1A} #{1B} #{1C} #{1D} #{1E} #{1F} #{20}
 #{21} #{22} #{23} #{24} #{25} #{26} #{27} #{28} #{29} #{2A} #{2B}
 #{2C} #{2D} #{2E} #{2F} #{30} #{31} #{32} #{33} #{34} #{35} #{36}
 #{37} #{38} #{39} #{3A} #{3B} #{3C} #{3D} #{3E} #{3F} #{40} #{41}
 #{42} #{43} #{44} #{45} #{46} #{47} #{48} #{49} #{4A} #{4B} #{4C}
 #{4D} #{4E} #{4F} #{50} #{51} #{52} #{53} #{54} #{55} #{56} #{57}
 #{58} #{59} #{5A} #{5B} #{5C} #{5D} #{5E} #{5F} #{60} #{61} #{62}
 #{63} #{64} #{65} #{66} #{67} #{68} #{69} #{6A} #{6B} #{6C} #{6D}
 #{6E} #{6F} #{70} #{71} #{72} #{73} #{74} #{75} #{76} #{77} #{78}
 #{79} #{7A} #{7B} #{7C} #{7D} #{7E} #{7F} #{E282AC} #{3F}
 #{E2809A} #{C692} #{E2809E} #{E280A6} #{E280A0} #{E280A1} #{CB86}
 #{E280B0} #{3F} #{E280B9} #{C592} #{3F} #{3F} #{3F} #{3F}
 #{E28098} #{E28099} #{E2809C} #{E2809D} #{E280A2} #{E28093}
 #{E28094} #{CB9C} #{E284A2} #{3F} #{E280BA} #{C593} #{3F} #{3F}
 #{C5B8} #{C2A0} #{C2A1} #{C2A2} #{C2A3} #{C2A4} #{C2A5} #{C2A6}
 #{C2A7} #{C2A8} #{C2A9} #{C2AA} #{C2AB} #{C2AC} #{C2AD} #{C2AE}
 #{C2AF} #{C2B0} #{C2B1} #{C2B2} #{C2B3} #{C2B4} #{C2B5} #{C2B6}
 #{C2B7} #{C2B8} #{C2B9} #{C2BA} #{C2BB} #{C2BC} #{C2BD} #{C2BE}
 #{C2BF} #{C380} #{C381} #{C382} #{C482} #{C384} #{C385} #{C386}
 #{C387} #{C388} #{C389} #{C38A} #{C38B} #{CC80} #{C38D} #{C38E}
 #{C38F} #{C490} #{C391} #{CC89} #{C393} #{C394} #{C6A0} #{C396}
 #{C397} #{C398} #{C399} #{C39A} #{C39B} #{C39C} #{C6AF} #{CC83}
 #{C39F} #{C3A0} #{C3A1} #{C3A2} #{C483} #{C3A4} #{C3A5} #{C3A6}
 #{C3A7} #{C3A8} #{C3A9} #{C3AA} #{C3AB} #{CC81} #{C3AD} #{C3AE}
 #{C3AF} #{C491} #{C3B1} #{CCA3} #{C3B3} #{C3B4} #{C6A1} #{C3B6}
 #{C3B7} #{C3B8} #{C3B9} #{C3BA} #{C3BB} #{C3BC} #{C6B0} #{E282AB}
 #{C3BF}
]

base64 is included for completeness.

List of supported encodings +≡

base64: make-encoding [
 encode: func [output text] [append output enbase text]
 decode: func [output text] [append output debase text]
]

The utf-7-imap encoding is used in IMAP to encode folder names.

List of supported encodings +≡

utf-7-imap: make-encoding [
 special: charset [#"^@" - #"^_" #"&" #"^~"]
 normal: exclude ascii-char special
 decode: func [result text /local mk1 mk2] [
  parse/all text [
   some [
    mk1: some normal mk2: (insert/part tail result mk1 mk2)
    |
    "&-" (append result #"&")
    |
    #"&" copy mk1 to #"-" skip (modbase64-to-utf8 result mk1)
    |
    mk1: skip (append result mk1/1) ; invalid character
   ]
  ]
  result
 ]
 modbase64-to-utf8: func [output encoded] [
  encoded: debase
   append
    replace/all encoded #"," #"/"
    pick ["" "===" "==" "="] 1 + remainder length? encoded 4
  forskip encoded 2 [
   append output encode-utf8 to integer! copy/part encoded 2
  ]
 ]
 int-to-16bit: func [int] [
  debase/base skip to-hex int 4 16
 ]
 encode: func [output text /local mk1 mk2 buffer] [
  parse/all text [
   some [
    mk1: some normal mk2: (insert/part tail output mk1 mk2)
    |
    #"&" (append output "&-")
    |
    (buffer: clear #{})
    some [
     copy mk1 [
      special | utf8-seq2 utf8-seq |
      utf8-seq3 2 utf8-seq | utf8-seq4 3 utf8-seq
     ] (
      ; this is not really correct... only valid for code points < 65536
      append buffer int-to-16bit decode-utf8 mk1
     )
    ]
    (
     buffer: replace/all trim/with enbase buffer #"=" #"/" #","
     insert insert insert tail output #"&" buffer #"-"
    )
   ]
  ]
  output
 ]
]

The quoted-printable encoding is used in email to encode 8-bit charsets into 7-bit ascii. The quoted-printable+ version also encodes spaces, and can be used in email headers.

List of supported encodings +≡

quoted-printable: quoted-printable+: make-encoding [
 underscore: no
 special: charset [#"^@" - #" " "=_?^~"]
 qp-chars: complement charset "=_"
 decode: func [result text /local mk1 mk2] [
  parse/all text [
   some [
    mk1: some qp-chars mk2: (insert/part tail result mk1 mk2)
    |
    "=^M^/" | "=^/" ; ignore
    |
    #"=" copy mk1 2 skip (append result debase/base mk1 16)
    |
    #"_" (append result pick [#" " #"_"] underscore)
   ]
  ]
  result
 ]
 add-newline: func [output /local pos] [
  if underscore [return none]
  pos: any [find/last output newline output]
  if 60 < length? pos [
   append output "=^/"
  ]
  length? pos
 ]
 encode-ascii: func [output start end /local l e] [
  if l: add-newline output [
   while [l + (offset? start end) > 60] [
    e: skip start 60 - l
    insert insert/part tail output start e "=^/"
    l: 0 start: e
   ]
  ]
  insert/part tail output start end
 ]
 encode-sequence: func [output start end] [
  start: copy/part start end
  switch/default start [
   " " [append output pick [#"_" #" "] underscore]
   "_" [append output pick ["=5F" #"_"] underscore]
   "?" [append output pick ["=3F" #"?"] underscore]
   "^/" [append output pick ["=0A" #"^/"] underscore]
   "^M" [append output pick ["=0D" #"^M"] underscore]
  ] [
   start: enbase/base start 16
   forskip start 2 [
    insert/part insert tail output #"=" start 2
   ]
  ]
  add-newline output
 ]
]
quoted-printable+: make quoted-printable+ [underscore: yes]

The html encoding is used in HTML to encode all Unicode characters in 7-bit ascii, and to escape HTML's special characters. html is an alias for html-ascii that encodes all non-ASCII characters (plus, of course, the HTML special characters) into an HTML entity. html-utf8 instead will only encode named entities, and leave any other UTF-8 sequence intact (use this if the browser can display UTF-8 correctly, and your text has a lot of non-ASCII characters, for example Chinese or Japanese text and so on, as UTF-8 is more space efficient than HTML entities).

List of supported encodings +≡

html: html-ascii: html-utf8: make-encoding [
 utf8?: no
 special: html-special-char
 encode-ascii: func [output start end] [insert/part tail output start end]
 encode-sequence: func [output start end /local char nm] [
  char: as-binary copy/part start end
  if nm: rselect entity-map char [
   insert insert insert tail output #"&" nm #";"
   exit
  ]
  if utf8? [
   append output char
   exit
  ]
  char: decode-utf8 char
  insert insert insert tail output "&#" char #";"
 ]
 decode-inplace: func [text /local txt mk1 mk2] [
  parse/all text [
   any [
    to #"&" mk1: skip [
     copy txt name #";" mk2: :mk1 (change/part mk1 entity-to-char txt mk2)
     |
     "#x" copy txt some hexdigit #";" mk2: :mk1 (change/part mk1 hex-to-utf8char txt mk2)
     |
     #"#" copy txt some digit #";" mk2: :mk1 (change/part mk1 dec-to-utf8char txt mk2)
     |
     none
    ]
   ]
  ]
  text
 ]
 decode: func [output text /local txt mk1 mk2] [
  parse/all text [
   any [
    mk1: to #"&" mk2: (insert/part tail output mk1 mk2)
    #"&" [
     copy txt name #";" (append output entity-to-char txt)
     |
     "#x" copy txt some hexdigit #";" (append output hex-to-utf8char txt)
     |
     #"#" copy txt some digit #";" (append output dec-to-utf8char txt)
     |
     none (append output #"&")
    ]
    |
    ; copy to end
    (append output mk1)
    end skip
   ]
  ]
  output
 ]
]
html-utf8: make html-utf8 [utf8?: yes]

The url encoding is used in URIs to encode reserved characters and non-ascii characters using "percent encoding". The url+ encoding encodes spaces with a "+" instead of "%20", and decodes "+" as a space.

List of supported encodings +≡

url: url+: make-encoding [
 plus?: no
 special: charset [#"^@" - #" " {!"#$%&'()*+,:;<=>?@[\]^^`{|}^~}]
 unreserved: union alpha-char union digit charset "-._~/"
 url-chars: complement charset "+%"
 decode-inplace: func [string /local here] [
  parse/all string [
   any [
    some url-chars
    |
    #"%" here: 2 hexdigit :here (
     change/part
      back here
      debase/base copy/part here 2 16
      skip here 2
    )
    |
    here: #"+" (
     if plus? [
      here/1: #" "
     ]
    )
    |
    skip
   ]
  ]
  string
 ]
 encode-inplace: func [string /local here] [
  parse/all string [
   any [
    some unreserved
    |
    here: skip (
     either all [plus? here/1 = #" "] [
      here/1: #"+"
      here: next here
     ] [
      here: change/part
       here
       join "%" enbase/base copy/part here 1 16
       next here
     ]
    ) :here
   ]
  ]
  string
 ]
 decode: func [output text /local start end] [
  parse/all text [
   any [
    start: some url-chars end: (insert/part tail output start end)
    |
    #"%" copy start 2 hexdigit (
     append output debase/base start 16
    )
    |
    #"+" (append output pick [#" " #"+"] plus?)
    |
    copy start skip (append output start)
   ]
  ]
  output
 ]
 encode-ascii: func [output start end] [insert/part tail output start end]
 encode-sequence: func [output start end] [
  start: copy/part start end
  either all [plus? start = " "] [
   append output #"+"
  ] [
   start: enbase/base start 16
   forskip start 2 [
    insert/part insert tail output #"%" start 2
   ]
  ]
 ]
]
url+: make url [plus?: yes]

The json encoding can be used to "escape" strings for Javascript and JSON. json is an alias for json-ascii that encodes all non-ASCII characters with an escape sequence; json-utf8 instead only encodes control characters and string delimiters.

List of supported encodings +≡

json: json-ascii: json-utf8: make-encoding [
 utf8?: no
 special: charset [#"^@" - #"^_" {\/"}]
 encode-ascii: func [output start end] [insert/part tail output start end]
 encode-sequence: func [output start end /local char nm] [
  char: as-binary copy/part start end
  append output switch/default char [
   #{08} ["\b"]
   #{09} ["\t"]
   #{0A} ["\n"]
   #{0C} ["\f"]
   #{0D} ["\r"]
   #{22} [{\"}]
   #{2F} ["\/"]
   #{5C} ["\\"]
  ] [
   either all [utf8? 1 < length? char] [
    char
   ] [
    char: decode-utf8 char
    append output "\u"
    skip to-hex char 4
   ]
  ]
 ]
 decode: func [output text /local txt mk1 mk2] [
  parse/all text [
   any [
    mk1: to #"\" mk2: (insert/part tail output mk1 mk2)
    #"\" [
     #"u" copy txt some hexdigit (append output hex-to-utf8char txt)
     |
     #"b" (append output #"^H")
     |
     #"t" (append output #"^-")
     |
     #"n" (append output #"^/")
     |
     #"f" (append output #"^L")
     |
     #"r" (append output #"^M")
     |
     copy txt skip (append output txt)
    ]
    |
    ; copy to end
    (append output mk1)
    end skip
   ]
  ]
  output
 ]
]
json-utf8: make json-utf8 [utf8?: yes]

6. Support functions

The make-encoding function is used above to factor out a number of recurring cases for the encoding objects.

Support functions

make-encoding: func [spec [none! block!]] [
 case [
  none? spec [
   context [
    decode-inplace: func [text] [text]
    encode-inplace: func [text] [text]
    decode: func [output text] [append output text]
    encode-ascii: encode-sequence: func [output start end] [insert/part tail output start end]
   ]
  ]
  parse spec [256 binary!] [
   context [
    map: spec
    decode: func [output text] [
     foreach char text [
      append output pick map 1 + to integer! char
     ]
     output
    ]
    map-char: func [char result /local pos] [
     pos: any [
      find map as-binary char
      find map #{3F}
      find map #{20}
     ]
     if pos [
      append result to char! -1 + index? pos
     ]
    ]
    encode-ascii: func [output start end] [
     for pos start back end 1 [
      map-char copy/part pos 1 output
     ]
    ]
    encode-sequence: func [output start end] [
     map-char copy/part start end output
    ]
   ]
  ]
  'else [
   context spec
  ]
 ]
]

The encodings object contains all the encoding objects that represent the supported text encodings.

Support functions +≡

encodings: context [
 List of supported encodings
]

parse-utf8 drives the UTF-8 encoding process in the most common case. The functions encode-ascii and encode-sequence in the encoding object are called to respectively encode an ascii string and a single Unicode character represented as a UTF-8 sequence.

The function also supports a set of "special" ASCII characters that need to be handled separately from the rest; for example, see the html and the quoted-printable encodings.

Support functions +≡

empty-charset: charset ""
parse-utf8: func [text output encoding /local ascii-minus-special special mk1 mk2] [
 either in encoding 'special [
  ascii-minus-special: exclude ascii-char special: encoding/special
 ] [
  ascii-minus-special: ascii-char
  special: empty-charset
 ]
 parse/all text [
  some [
   mk1: some ascii-minus-special mk2: (encoding/encode-ascii output mk1 mk2)
   |
   mk1: [
    special | utf8-seq2 utf8-seq |
    utf8-seq3 2 utf8-seq | utf8-seq4 3 utf8-seq
   ] mk2: (encoding/encode-sequence output mk1 mk2)
   |
   skip
  ]
 ]
 output
]

The following functions are helpers used by the HTML encoding object.

Support functions +≡

rselect: func [series value] [
 all [
  series: find series value
  pick series -1
 ]
]
entity-map: [
 Named HTML entities map
]
entity-to-char: func [name] [
 as-string any [select/case entity-map name ""]
]
hex-to-utf8char: func [hex] [
 encode-utf8 to integer! to issue! hex
]
dec-to-utf8char: func [dec] [
 encode-utf8 to integer! dec
]

encode-utf8 and decode-utf8 are used by the various encoding to respectively encode a Unicode character to its UTF-8 representation, and to decode a UTF-8 sequence to the Unicode character it represents.

Support functions +≡

encode-utf8: func [
 "Encode a code point in UTF-8 format"
 char [integer!] "Unicode code point"
] [
 Encode the code point char in UTF-8 format
]
decode-utf8: func [
 "Decode a UTF-8 sequence into a code point"
 char [any-string!] {Valid UTF-8 sequence representing a single character}
] [
 Decode the UTF-8 sequence in char into a code point
]

6.1 Named HTML entities map

This is a map of all HTML named entities to their UTF-8 encoded character value.

Named HTML entities map

"quot" #{22}
"amp" #{26}
"lt" #{3C}
"gt" #{3E}
"nbsp" #{C2A0}
"iexcl" #{C2A1}
"cent" #{C2A2}
"pound" #{C2A3}
"curren" #{C2A4}
"yen" #{C2A5}
"brvbar" #{C2A6}
"sect" #{C2A7}
"uml" #{C2A8}
"copy" #{C2A9}
"ordf" #{C2AA}
"laquo" #{C2AB}
"not" #{C2AC}
"shy" #{C2AD}
"reg" #{C2AE}
"macr" #{C2AF}
"deg" #{C2B0}
"plusmn" #{C2B1}
"sup2" #{C2B2}
"sup3" #{C2B3}
"acute" #{C2B4}
"micro" #{C2B5}
"para" #{C2B6}
"middot" #{C2B7}
"cedil" #{C2B8}
"sup1" #{C2B9}
"ordm" #{C2BA}
"raquo" #{C2BB}
"frac14" #{C2BC}
"frac12" #{C2BD}
"frac34" #{C2BE}
"iquest" #{C2BF}
"Agrave" #{C380}
"Aacute" #{C381}
"Acirc" #{C382}
"Atilde" #{C383}
"Auml" #{C384}
"Aring" #{C385}
"AElig" #{C386}
"Ccedil" #{C387}
"Egrave" #{C388}
"Eacute" #{C389}
"Ecirc" #{C38A}
"Euml" #{C38B}
"Igrave" #{C38C}
"Iacute" #{C38D}
"Icirc" #{C38E}
"Iuml" #{C38F}
"ETH" #{C390}
"Ntilde" #{C391}
"Ograve" #{C392}
"Oacute" #{C393}
"Ocirc" #{C394}
"Otilde" #{C395}
"Ouml" #{C396}
"times" #{C397}
"Oslash" #{C398}
"Ugrave" #{C399}
"Uacute" #{C39A}
"Ucirc" #{C39B}
"Uuml" #{C39C}
"Yacute" #{C39D}
"THORN" #{C39E}
"szlig" #{C39F}
"agrave" #{C3A0}
"aacute" #{C3A1}
"acirc" #{C3A2}
"atilde" #{C3A3}
"auml" #{C3A4}
"aring" #{C3A5}
"aelig" #{C3A6}
"ccedil" #{C3A7}
"egrave" #{C3A8}
"eacute" #{C3A9}
"ecirc" #{C3AA}
"euml" #{C3AB}
"igrave" #{C3AC}
"iacute" #{C3AD}
"icirc" #{C3AE}
"iuml" #{C3AF}
"eth" #{C3B0}
"ntilde" #{C3B1}
"ograve" #{C3B2}
"oacute" #{C3B3}
"ocirc" #{C3B4}
"otilde" #{C3B5}
"ouml" #{C3B6}
"divide" #{C3B7}
"oslash" #{C3B8}
"ugrave" #{C3B9}
"uacute" #{C3BA}
"ucirc" #{C3BB}
"uuml" #{C3BC}
"yacute" #{C3BD}
"thorn" #{C3BE}
"yuml" #{C3BF}
"fnof" #{C692}
"Alpha" #{CE91}
"Beta" #{CE92}
"Gamma" #{CE93}
"Delta" #{CE94}
"Epsilon" #{CE95}
"Zeta" #{CE96}
"Eta" #{CE97}
"Theta" #{CE98}
"Iota" #{CE99}
"Kappa" #{CE9A}
"Lambda" #{CE9B}
"Mu" #{CE9C}
"Nu" #{CE9D}
"Xi" #{CE9E}
"Omicron" #{CE9F}
"Pi" #{CEA0}
"Rho" #{CEA1}
"Sigma" #{CEA3}
"Tau" #{CEA4}
"Upsilon" #{CEA5}
"Phi" #{CEA6}
"Chi" #{CEA7}
"Psi" #{CEA8}
"Omega" #{CEA9}
"alpha" #{CEB1}
"beta" #{CEB2}
"gamma" #{CEB3}
"delta" #{CEB4}
"epsilon" #{CEB5}
"zeta" #{CEB6}
"eta" #{CEB7}
"theta" #{CEB8}
"iota" #{CEB9}
"kappa" #{CEBA}
"lambda" #{CEBB}
"mu" #{CEBC}
"nu" #{CEBD}
"xi" #{CEBE}
"omicron" #{CEBF}
"pi" #{CF80}
"rho" #{CF81}
"sigmaf" #{CF82}
"sigma" #{CF83}
"tau" #{CF84}
"upsilon" #{CF85}
"phi" #{CF86}
"chi" #{CF87}
"psi" #{CF88}
"omega" #{CF89}
"thetasym" #{CF91}
"upsih" #{CF92}
"piv" #{CF96}
"bull" #{E280A2}
"hellip" #{E280A6}
"prime" #{E280B2}
"Prime" #{E280B3}
"oline" #{E280BE}
"frasl" #{E28184}
"weierp" #{E28498}
"image" #{E28491}
"real" #{E2849C}
"trade" #{E284A2}
"alefsym" #{E284B5}
"larr" #{E28690}
"uarr" #{E28691}
"rarr" #{E28692}
"darr" #{E28693}
"harr" #{E28694}
"crarr" #{E286B5}
"lArr" #{E28790}
"uArr" #{E28791}
"rArr" #{E28792}
"dArr" #{E28793}
"hArr" #{E28794}
"forall" #{E28880}
"part" #{E28882}
"exist" #{E28883}
"empty" #{E28885}
"nabla" #{E28887}
"isin" #{E28888}
"notin" #{E28889}
"ni" #{E2888B}
"prod" #{E2888F}
"sum" #{E28891}
"minus" #{E28892}
"lowast" #{E28897}
"radic" #{E2889A}
"prop" #{E2889D}
"infin" #{E2889E}
"ang" #{E288A0}
"and" #{E288A7}
"or" #{E288A8}
"cap" #{E288A9}
"cup" #{E288AA}
"int" #{E288AB}
"there4" #{E288B4}
"sim" #{E288BC}
"cong" #{E28985}
"asymp" #{E28988}
"ne" #{E289A0}
"equiv" #{E289A1}
"le" #{E289A4}
"ge" #{E289A5}
"sub" #{E28A82}
"sup" #{E28A83}
"nsub" #{E28A84}
"sube" #{E28A86}
"supe" #{E28A87}
"oplus" #{E28A95}
"otimes" #{E28A97}
"perp" #{E28AA5}
"sdot" #{E28B85}
"lceil" #{E28C88}
"rceil" #{E28C89}
"lfloor" #{E28C8A}
"rfloor" #{E28C8B}
"lang" #{E28CA9}
"rang" #{E28CAA}
"loz" #{E2978A}
"spades" #{E299A0}
"clubs" #{E299A3}
"hearts" #{E299A5}
"diams" #{E299A6}
"OElig" #{C592}
"oelig" #{C593}
"Scaron" #{C5A0}
"scaron" #{C5A1}
"Yuml" #{C5B8}
"circ" #{CB86}
"tilde" #{CB9C}
"ensp" #{E28082}
"emsp" #{E28083}
"thinsp" #{E28089}
"zwnj" #{E2808C}
"zwj" #{E2808D}
"lrm" #{E2808E}
"rlm" #{E2808F}
"ndash" #{E28093}
"mdash" #{E28094}
"lsquo" #{E28098}
"rsquo" #{E28099}
"sbquo" #{E2809A}
"ldquo" #{E2809C}
"rdquo" #{E2809D}
"bdquo" #{E2809E}
"dagger" #{E280A0}
"Dagger" #{E280A1}
"permil" #{E280B0}
"lsaquo" #{E280B9}
"rsaquo" #{E280BA}
"euro" #{E282AC}

7. Encode the code point char in UTF-8 format

Encode the code point char in UTF-8 format

if char <= 127 [
 return as-string to binary! reduce [char]
]
if char <= 2047 [
 return as-string to binary! reduce [
  char and 1984 / 64 + 192
  char and 63 + 128
 ]
]
if char <= 65535 [
 return as-string to binary! reduce [
  char and 61440 / 4096 + 224
  char and 4032 / 64 + 128
  char and 63 + 128
 ]
]
if char > 2097151 [return ""]
as-string to binary! reduce [
 char and 1835008 / 262144 + 240
 char and 258048 / 4096 + 128
 char and 4032 / 64 + 128
 char and 63 + 128
]

8. Decode the UTF-8 sequence in char into a code point

Decode the UTF-8 sequence in char into a code point

unless binary? char [char: as-binary char]
do pick [
 [ ; 1 (ASCII)
  char/1
 ]
 [ ; 2
  char/1 and 31 * 64 + (char/2 and 63)
 ]
 [ ; 3
  char/1 and 15 * 4096 + (char/2 and 63 * 64) + (char/3 and 63)
 ]
 [ ; 4
  char/1 and 7 * 262144 + (char/2 and 63 * 4096) + (char/3 and 63 * 64) + (char/4 and 63)
 ]
] length? char