| 1 |
This is recode.info, produced by makeinfo version 7.1 from recode.texi. |
| 2 |
|
| 3 |
INFO-DIR-SECTION Internationalization and character sets |
| 4 |
START-INFO-DIR-ENTRY |
| 5 |
* recode: (recode). Conversion between character sets and surfaces. |
| 6 |
END-INFO-DIR-ENTRY |
| 7 |
|
| 8 |
This file documents the Recode program and library, which has the |
| 9 |
purpose of converting files between various character sets and surfaces. |
| 10 |
|
| 11 |
Copyright (C) 1990-2023 Free Software Foundation, Inc. |
| 12 |
|
| 13 |
Permission is granted to make and distribute verbatim copies of this |
| 14 |
manual provided the copyright notice and this permission notice are |
| 15 |
preserved on all copies. |
| 16 |
|
| 17 |
Permission is granted to copy and distribute modified versions of |
| 18 |
this manual under the conditions for verbatim copying, provided that the |
| 19 |
entire resulting derived work is distributed under the terms of a |
| 20 |
permission notice identical to this one. |
| 21 |
|
| 22 |
Permission is granted to copy and distribute translations of this |
| 23 |
manual into another language, under the above conditions for modified |
| 24 |
versions, except that this permission notice may be stated in a |
| 25 |
translation approved by the Foundation. |
| 26 |
|
| 27 |
|
| 28 |
File: recode.info, Node: Top, Next: Tutorial, Prev: (dir), Up: (dir) |
| 29 |
|
| 30 |
Recode |
| 31 |
****** |
| 32 |
|
| 33 |
This recoding library converts files between various coded character |
| 34 |
sets and surface encodings. When this cannot be achieved exactly, it |
| 35 |
may get rid of the offending characters or fall back on approximations. |
| 36 |
The library recognises or produces more than 300 different character |
| 37 |
sets and is able to convert files between almost any pair. Most |
| 38 |
RFC 1345 character sets, and all character sets from a pre-installed |
| 39 |
‘iconv’ library, are supported. The ‘recode’ program is a handy |
| 40 |
front-end to the library. |
| 41 |
|
| 42 |
This manual documents Recode 3.7.15. |
| 43 |
|
| 44 |
* Menu: |
| 45 |
|
| 46 |
* Tutorial:: Quick Tutorial |
| 47 |
* Introduction:: Terminology and purpose |
| 48 |
* Invoking recode:: How to use this program |
| 49 |
* Library:: A recoding library |
| 50 |
* Universal:: The universal charset |
| 51 |
* iconv:: The ‘iconv’ library |
| 52 |
* Tabular:: Tabular sources (RFC 1345) |
| 53 |
* ASCII misc:: ASCII and some derivatives |
| 54 |
* IBM and MS:: Some IBM or Microsoft charsets |
| 55 |
* CDC:: Charsets for CDC machines |
| 56 |
* Micros:: Other micro-computer charsets |
| 57 |
* Miscellaneous:: Various other charsets |
| 58 |
* Surfaces:: All about surfaces |
| 59 |
* Internals:: Internal aspects |
| 60 |
* Concept Index:: Concept Index |
| 61 |
* Option Index:: Option Index |
| 62 |
* Library Index:: Library Index |
| 63 |
* Charset and Surface Index:: Charset and Surface Index |
| 64 |
|
| 65 |
-- The Detailed Node Listing -- |
| 66 |
|
| 67 |
Terminology and purpose |
| 68 |
|
| 69 |
* Charset overview:: Overview of charsets |
| 70 |
* Surface overview:: Overview of surfaces |
| 71 |
* Contributing:: Contributions and bug reports |
| 72 |
|
| 73 |
How to use this program |
| 74 |
|
| 75 |
* Synopsis:: Synopsis of ‘recode’ call |
| 76 |
* Requests:: The REQUEST parameter |
| 77 |
* Listings:: Asking for various lists |
| 78 |
* Recoding:: Controlling how files are recoded |
| 79 |
* Reversibility:: Reversibility issues |
| 80 |
* Sequencing:: Selecting sequencing methods |
| 81 |
* Mixed:: Using mixed charset input |
| 82 |
* Emacs:: Using Recode within Emacs |
| 83 |
* Debugging:: Debugging considerations |
| 84 |
|
| 85 |
A recoding library |
| 86 |
|
| 87 |
* Outer level:: Outer level functions |
| 88 |
* Request level:: Request level functions |
| 89 |
* Task level:: Task level functions |
| 90 |
* Charset level:: Charset level functions |
| 91 |
* Errors:: Handling errors |
| 92 |
|
| 93 |
The universal charset |
| 94 |
|
| 95 |
* UCS-2:: Universal Character Set, 2 bytes |
| 96 |
* UCS-4:: Universal Character Set, 4 bytes |
| 97 |
* UTF-7:: Universal Transformation Format, 7 bits |
| 98 |
* UTF-8:: Universal Transformation Format, 8 bits |
| 99 |
* UTF-16:: Universal Transformation Format, 16 bits |
| 100 |
* count-characters:: Frequency count of characters |
| 101 |
* dump-with-names:: Fully interpreted UCS dump |
| 102 |
|
| 103 |
ASCII and some derivatives |
| 104 |
|
| 105 |
* ASCII:: Usual ASCII |
| 106 |
* ISO 8859:: ASCII extended by Latin Alphabets |
| 107 |
* ASCII-BS:: ASCII 7-bits, ‘BS’ to overstrike |
| 108 |
* flat:: ASCII without diacritics nor underline |
| 109 |
|
| 110 |
Some IBM or Microsoft charsets |
| 111 |
|
| 112 |
* EBCDIC:: EBCDIC codes |
| 113 |
* IBM-PC:: IBM's PC code |
| 114 |
* Icon-QNX:: Unisys' Icon code |
| 115 |
|
| 116 |
Charsets for CDC machines |
| 117 |
|
| 118 |
* Display Code:: Control Data's Display Code |
| 119 |
* CDC-NOS:: ASCII 6/12 from NOS |
| 120 |
* Bang-Bang:: ASCII "bang bang" |
| 121 |
|
| 122 |
Other micro-computer charsets |
| 123 |
|
| 124 |
* Mac OS:: Apple's Macintosh code |
| 125 |
* AtariST:: Atari ST code |
| 126 |
|
| 127 |
Various other charsets |
| 128 |
|
| 129 |
* HTML:: World Wide Web representations |
| 130 |
* LaTeX:: LaTeX macro calls |
| 131 |
* BibTeX:: BibTeX macro calls |
| 132 |
* Texinfo:: GNU project documentation files |
| 133 |
* ISO 5426 and ANSEL:: Bibliographic character sets |
| 134 |
* Vietnamese:: Vietnamese charsets |
| 135 |
* African:: African charsets |
| 136 |
* Others:: Cyrillic and other charsets |
| 137 |
* Java:: Java code |
| 138 |
* Texte:: Easy French conventions |
| 139 |
* Mule:: Mule as a multiplexed charset |
| 140 |
|
| 141 |
All about surfaces |
| 142 |
|
| 143 |
* Permutations:: Permuting groups of bytes |
| 144 |
* End lines:: Representation for end of lines |
| 145 |
* MIME:: MIME contents encodings |
| 146 |
* Dump:: Interpreted character dumps |
| 147 |
* Test:: Artificial data for testing |
| 148 |
|
| 149 |
Internal aspects |
| 150 |
|
| 151 |
* Main flow:: Overall organisation |
| 152 |
* New charsets:: Adding new charsets |
| 153 |
* New surfaces:: Adding new surfaces |
| 154 |
* Design:: Comments on the library design |
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
File: recode.info, Node: Tutorial, Next: Introduction, Prev: Top, Up: Top |
| 159 |
|
| 160 |
1 Quick Tutorial |
| 161 |
**************** |
| 162 |
|
| 163 |
So, really, you just are in a hurry to use Recode, and do not feel like |
| 164 |
studying this manual? Even reading this paragraph slows you down? We |
| 165 |
might have a problem, as you will have to do some guess work, and might |
| 166 |
not become very proficient unless you have a very solid intuition.... |
| 167 |
|
| 168 |
Let me use here, as a quick tutorial, an actual reply of mine to a |
| 169 |
Recode user, who writes: |
| 170 |
|
| 171 |
My situation is this--I occasionally get email with special |
| 172 |
characters in it. Sometimes this mail is from a user using IBM |
| 173 |
software and sometimes it is a user using Mac software. I myself |
| 174 |
am on a SPARC Solaris machine. |
| 175 |
|
| 176 |
Your situation is similar to mine, except that I _often_ receive |
| 177 |
email needing recoding, that is, much more than _occasionally_! The |
| 178 |
usual recodings I do are Mac to Latin-1, IBM page codes to Latin-1, |
| 179 |
Easy-French to Latin-1, remove Quoted-Printable, remove Base64. These |
| 180 |
are so frequent that I made myself a few two-keystroke Emacs commands to |
| 181 |
filter the Emacs region. This is very convenient for me. I also resort |
| 182 |
to many other email conversions, yet more rarely than the frequent cases |
| 183 |
above. |
| 184 |
|
| 185 |
It _seems_ like this should be doable using Recode. However, when |
| 186 |
I try something like ‘recode mac macfile.txt’ I get nothing out--no |
| 187 |
error, no output, nothing. |
| 188 |
|
| 189 |
*Note:* For the following discussion to be true, you should have |
| 190 |
something like ‘export LANG=fr_FR.ISO-8859-1’ in your environment, the |
| 191 |
important bit here being the specification of an preferred charset. |
| 192 |
|
| 193 |
Presuming you are using some recent version of Recode, the command: |
| 194 |
|
| 195 |
recode mac macfile.txt |
| 196 |
|
| 197 |
is a request for recoding ‘macfile.txt’ over itself, overwriting the |
| 198 |
original, from Macintosh usual character code and Macintosh end of |
| 199 |
lines, to Latin-1 and Unix end of lines. This is overwrite mode. If |
| 200 |
you want to use Recode as a filter, which is probably what you need, |
| 201 |
rather do: |
| 202 |
|
| 203 |
recode mac |
| 204 |
|
| 205 |
and give your Macintosh file as standard input, you'll get the Latin-1 |
| 206 |
file on standard output. The above command is an abbreviation for any |
| 207 |
of: |
| 208 |
|
| 209 |
recode mac.. |
| 210 |
recode mac..l1 |
| 211 |
recode mac..Latin-1 |
| 212 |
recode mac/CR..Latin-1/ |
| 213 |
recode Macintosh..ISO_8859-1 |
| 214 |
recode Macintosh/CR..ISO_8859-1/ |
| 215 |
|
| 216 |
That is, a ‘CR’ surface, encoding newlines with ASCII <CR>, is first |
| 217 |
to be removed (this is a default surface for ‘mac’), then the Macintosh |
| 218 |
charset is converted to Latin-1 and no surface is added to the result |
| 219 |
(there is no default surface for ‘l1’). If you want ‘mac’ code |
| 220 |
converted, but you know that newlines are already coded the Unix way, |
| 221 |
just do: |
| 222 |
|
| 223 |
recode mac/ |
| 224 |
|
| 225 |
the slash then overriding the default surface with empty, that is, none. |
| 226 |
Here are other easy recipes: |
| 227 |
|
| 228 |
recode pc to filter IBM-PC code and CR-LF (default) to Latin-1 |
| 229 |
recode pc/ to filter IBM-PC code to Latin-1 |
| 230 |
recode 850 to filter code page 850 and CR-LF (default) to Latin-1 |
| 231 |
recode 850/ to filter code page 850 to Latin-1 |
| 232 |
recode /qp to remove quoted printable |
| 233 |
|
| 234 |
The last one is indeed equivalent to any of: |
| 235 |
|
| 236 |
recode /qp.. |
| 237 |
recode l1/qp..l1/ |
| 238 |
recode ISO_8859-1/Quoted-Printable..ISO_8859-1/ |
| 239 |
|
| 240 |
Here are some reverse recipes: |
| 241 |
|
| 242 |
recode ..mac to filter Latin-1 to Macintosh code and CR (default) |
| 243 |
recode ..mac/ to filter Latin-1 to Macintosh code |
| 244 |
recode ..pc to filter Latin-1 to IBM-PC code and CR-LF (default) |
| 245 |
recode ..pc/ to filter Latin-1 to IBM-PC code |
| 246 |
recode ..850 to filter Latin-1 to code page 850 and CR-LF (default) |
| 247 |
recode ..850/ to filter Latin-1 to code page 850 |
| 248 |
recode ../qp to force quoted printable |
| 249 |
|
| 250 |
In all the above calls, replace ‘recode’ by ‘recode -f’ if you want |
| 251 |
to proceed despite recoding errors. If you do not use ‘-f’ and there is |
| 252 |
an error, the recoding output will be interrupted after first error in |
| 253 |
filter mode, or the file will not be replaced by a recoded copy in |
| 254 |
overwrite mode. |
| 255 |
|
| 256 |
You may use ‘recode -l’ to get a list of available charsets and |
| 257 |
surfaces, and ‘recode --help’ to get a quick summary of options. The |
| 258 |
above output is meant for those having already read this manual, so let |
| 259 |
me dare a suggestion: why could not you find a few more minutes in your |
| 260 |
schedule to peek further down, right into the following chapters! |
| 261 |
|
| 262 |
|
| 263 |
File: recode.info, Node: Introduction, Next: Invoking recode, Prev: Tutorial, Up: Top |
| 264 |
|
| 265 |
2 Terminology and purpose |
| 266 |
************************* |
| 267 |
|
| 268 |
A few terms are used over and over in this manual, our wise reader will |
| 269 |
learn their meaning right away. Both ISO (International Organization |
| 270 |
for Standardisation) and IETF (Internet Engineering Task Force) have |
| 271 |
their own terminology, this document does not try to stick to either one |
| 272 |
in a strict way, while it does not want to throw more confusion in the |
| 273 |
field. On the other hand, it would not be efficient using paraphrases |
| 274 |
all the time, so Recode coins a few short words, which are explained |
| 275 |
below. |
| 276 |
|
| 277 |
A “charset”, in the context of Recode, is a particular association |
| 278 |
between computer codes on one side, and a repertoire of intended |
| 279 |
characters on the other side. Codes are usually taken from a set of |
| 280 |
consecutive small integers, starting at 0. Some characters have a |
| 281 |
graphical appearance (glyph) or displayable effect, others have special |
| 282 |
uses like, for example, to control devices or to interact with |
| 283 |
neighbouring codes to specify them more precisely. So, a _charset_ is |
| 284 |
roughly one of those tables, giving a meaning to each of the codes from |
| 285 |
the set of allowable values. MIME also uses the term charset with |
| 286 |
approximately the same meaning. It does _not_ exactly corresponds to |
| 287 |
what ISO calls a “coded character set”, that is, a set of characters |
| 288 |
with an encoding for them. An coded character set does not necessarily |
| 289 |
use all available code positions, while a MIME charset usually tries to |
| 290 |
specify them all. A MIME charset might be the union of a few disjoint |
| 291 |
coded character sets. |
| 292 |
|
| 293 |
A “surface” is a term used in Recode only, and is a short for surface |
| 294 |
transformation of a charset stream. This is any kind of mapping, |
| 295 |
usually reversible, which associates physical bits in some medium for a |
| 296 |
stream of characters taken from one or more charsets (usually one). A |
| 297 |
surface is a kind of varnish added over a charset so it fits in actual |
| 298 |
bits and bytes. How end of lines are exactly encoded is not really |
| 299 |
pertinent to the charset, and so, there is surface for end of lines. |
| 300 |
‘Base64’ is also a surface, as we may encode any charset in it. Other |
| 301 |
examples would ‘DES’ enciphering, or ‘gzip’ compression (even if Recode |
| 302 |
does not offer them currently): these are ways to give a real life to |
| 303 |
theoretical charsets. The “trivial” surface consists into putting |
| 304 |
characters into fixed width little chunks of bits, usually eight such |
| 305 |
bits per character. But things are not always that simple. |
| 306 |
|
| 307 |
This Recode library, and the program by that name, have the purpose |
| 308 |
of converting files between various charsets and surfaces. When this |
| 309 |
cannot be done in exact ways, as it is often the case, the program may |
| 310 |
get rid of the offending characters or fall back on approximations. |
| 311 |
This library recognises or produces around 175 such charsets under 500 |
| 312 |
names, and handle a dozen surfaces. Since it can convert each charset |
| 313 |
to almost any other one, many thousands of different conversions are |
| 314 |
possible. |
| 315 |
|
| 316 |
The Recode program and library do not usually know how to split and |
| 317 |
sort out textual and non-textual information which may be mixed in a |
| 318 |
single input file. For example, there is no surface which currently |
| 319 |
addresses the problem of how lines are blocked into physical records, |
| 320 |
when the blocking information is added as binary markers or counters |
| 321 |
within files. So, Recode should be given textual streams which are |
| 322 |
rather _pure_. |
| 323 |
|
| 324 |
This tool pays special attention to superimposition of diacritics for |
| 325 |
some French representations. This orientation is mostly historical, it |
| 326 |
does not impair the usefulness, generality or extensibility of the |
| 327 |
program. ‘recode’ is both a French and English word. For those who pay |
| 328 |
attention to those things, the proper pronunciation is French (that is, |
| 329 |
‘racud’, with ‘a’ like in ‘above’, and ‘u’ like in ‘cut’). |
| 330 |
|
| 331 |
The Recode program and library has been written by François Pinard. |
| 332 |
With time, it got to reuse works from other contributors, and notably, |
| 333 |
those of Keld Simonsen and Bruno Haible. |
| 334 |
|
| 335 |
* Menu: |
| 336 |
|
| 337 |
* Charset overview:: Overview of charsets |
| 338 |
* Surface overview:: Overview of surfaces |
| 339 |
* Contributing:: Contributions and bug reports |
| 340 |
|
| 341 |
|
| 342 |
File: recode.info, Node: Charset overview, Next: Surface overview, Prev: Introduction, Up: Introduction |
| 343 |
|
| 344 |
2.1 Overview of charsets |
| 345 |
======================== |
| 346 |
|
| 347 |
Recoding is currently possible between many charsets, the bulk of which |
| 348 |
is described by RFC 1345 tables or available in a pre-installed external |
| 349 |
‘iconv’ library. *Note Tabular::, and *note iconv::(1). The Recode |
| 350 |
library also handles some charsets in some specialised ways. These are: |
| 351 |
|
| 352 |
• 6-bit charsets based on CDC display code: 6/12 code from NOS; |
| 353 |
bang-bang code from Université de Montréal; |
| 354 |
|
| 355 |
• 7-bit ASCII: without any diacritics, or else: using backspace for |
| 356 |
overstriking; Unisys' Icon convention; TeX/LaTeX coding; easy |
| 357 |
French conventions for electronic mail; |
| 358 |
|
| 359 |
• 8-bit extensions to ASCII: ISO Latin-1, Atari ST code, IBM's code |
| 360 |
for the PC, Apple's code for the Macintosh, ISO 5426 and ANSEL |
| 361 |
library codes; |
| 362 |
|
| 363 |
• 8-bit non-ASCII codes: three flavours of EBCDIC; |
| 364 |
|
| 365 |
• 16-bit or 31-bit universal characters, and their transfer |
| 366 |
encodings. |
| 367 |
|
| 368 |
The introduction of RFC 1345 in Recode has brought with it a few |
| 369 |
charsets having the functionality of older ones, but yet being different |
| 370 |
in subtle ways. The effects have not been fully investigated yet, so |
| 371 |
for now, clashes are avoided, the old and new charsets are kept well |
| 372 |
separate. |
| 373 |
|
| 374 |
Conversion is possible between almost any pair of charsets. Here is |
| 375 |
a list of the exceptions. One may not recode _from_ the ‘flat’, |
| 376 |
‘count-characters’ or ‘dump-with-names’ charsets, nor _from_ or _to_ the |
| 377 |
‘data’ or ‘:iconv:’ charsets. Also, if we except the ‘data’ |
| 378 |
pseudo-charset, charsets and surfaces live in disjoint recoding spaces, |
| 379 |
one cannot really transform a surface into a charset or vice-versa, as |
| 380 |
surfaces are only meant to be applied over charsets, or removed from |
| 381 |
them. |
| 382 |
|
| 383 |
---------- Footnotes ---------- |
| 384 |
|
| 385 |
(1) Because ‘iconv’ can vary from system to system, and is itself a |
| 386 |
complex tool, it can cause recode to behave in unexpected ways. |
| 387 |
Therefore, by default it is only used when a conversion would not be |
| 388 |
possible without it. To request that ‘iconv’ be used, use |
| 389 |
‘--prefer-iconv’; see *Note prefer-iconv::. Conversely, you can disable |
| 390 |
it with the ‘-x:’ option; see *Note disable-iconv::. |
| 391 |
|
| 392 |
|
| 393 |
File: recode.info, Node: Surface overview, Next: Contributing, Prev: Charset overview, Up: Introduction |
| 394 |
|
| 395 |
2.2 Overview of surfaces |
| 396 |
======================== |
| 397 |
|
| 398 |
For various practical considerations, it sometimes happens that the |
| 399 |
codes making up a text, written in a particular charset, cannot simply |
| 400 |
be put out in a file one after another without creating problems or |
| 401 |
breaking other things. Sometimes, 8-bit codes cannot be written on a |
| 402 |
7-bit medium, variable length codes need kind of envelopes, newlines |
| 403 |
require special treatment, etc. We sometimes have to apply “surfaces” |
| 404 |
to a stream of codes, which surfaces are kind of tricks used to fit the |
| 405 |
charset into those practical constraints. Moreover, similar surfaces or |
| 406 |
tricks may be useful for many unrelated charsets, and many surfaces can |
| 407 |
be used at once over a single charset. |
| 408 |
|
| 409 |
So, Recode has machinery to describe a combination of a charset with |
| 410 |
surfaces used over it in a file. We would use the expression “pure |
| 411 |
charset” for referring to a charset free of any surface, that is, the |
| 412 |
conceptual association between integer codes and character intents. |
| 413 |
|
| 414 |
It is not always clear if some transformation will yield a charset or |
| 415 |
a surface, especially for those transformations which are only |
| 416 |
meaningful over a single charset. The Recode library is not overly |
| 417 |
picky as identifying surfaces as such: when it is practical to consider |
| 418 |
a specialised surface as if it were a charset, this is preferred, and |
| 419 |
done. |
| 420 |
|
| 421 |
|
| 422 |
File: recode.info, Node: Contributing, Prev: Surface overview, Up: Introduction |
| 423 |
|
| 424 |
2.3 Contributions and bug reports |
| 425 |
================================= |
| 426 |
|
| 427 |
Even being the Recode author and current maintainer, I am no specialist |
| 428 |
in charset standards. I only made Recode along the years to solve my |
| 429 |
own needs, but felt it was applicable for the needs of others. Some FSF |
| 430 |
people liked the program structure and suggested to make it more widely |
| 431 |
available. I often rely on Recode users suggestions to decide what is |
| 432 |
best to be done next. |
| 433 |
|
| 434 |
Properly protecting Recode about possible copyright fights is a pain |
| 435 |
for me and for contributors, but we cannot avoid addressing the issue in |
| 436 |
the long run. Besides, the Free Software Foundation, which mandates the |
| 437 |
GNU project, is very sensible to this matter. GNU standards suggest |
| 438 |
that we stay cautious before looking at copyrighted code. The safest |
| 439 |
and simplest way for me is to gather ideas and reprogram them anew, even |
| 440 |
if this might slow me down considerably. For contributions going beyond |
| 441 |
a few lines of code here and there, the FSF definitely requires employer |
| 442 |
disclaimers and copyright assignments in writing. |
| 443 |
|
| 444 |
When you contribute something to Recode, _please_ explain what it is |
| 445 |
about. Do not take for granted that I know those charsets which are |
| 446 |
familiar to you. Once again, I'm no expert, and you have to help me. |
| 447 |
Your explanations could well find their way into this documentation, |
| 448 |
too. Also, for contributing new charsets or new surfaces, as much as |
| 449 |
possible, please provide good, solid, verifiable references for the |
| 450 |
tables you used(1). |
| 451 |
|
| 452 |
Many users contributed to Recode already, I am grateful to them for |
| 453 |
their interest and involvement. Some suggestions can be integrated |
| 454 |
quickly while some others have to be delayed, I have to draw a line |
| 455 |
somewhere when time comes to make a new release, about what would go in |
| 456 |
it and what would go in the next. |
| 457 |
|
| 458 |
Please report suggestions, documentation errors and bugs at |
| 459 |
<https://github.com/rrthomas/recode>. Do not be afraid to report |
| 460 |
details, because this program is the mere aggregation of hundreds of |
| 461 |
details. |
| 462 |
|
| 463 |
---------- Footnotes ---------- |
| 464 |
|
| 465 |
(1) I'm not prone to accept a charset you just invented, and which |
| 466 |
nobody uses yet: convince your friends and community first! |
| 467 |
|
| 468 |
|
| 469 |
File: recode.info, Node: Invoking recode, Next: Library, Prev: Introduction, Up: Top |
| 470 |
|
| 471 |
3 How to use this program |
| 472 |
************************* |
| 473 |
|
| 474 |
With the synopsis of the ‘recode’ call, we stress the difference between |
| 475 |
using this program as a file filter, or recoding many files at once. |
| 476 |
The first parameter of any call states the recoding request, and this |
| 477 |
deserves a section on its own. Options are then presented, but somewhat |
| 478 |
grouped according to the related functionalities they control. |
| 479 |
|
| 480 |
* Menu: |
| 481 |
|
| 482 |
* Synopsis:: Synopsis of ‘recode’ call |
| 483 |
* Requests:: The REQUEST parameter |
| 484 |
* Listings:: Asking for various lists |
| 485 |
* Recoding:: Controlling how files are recoded |
| 486 |
* Reversibility:: Reversibility issues |
| 487 |
* Sequencing:: Selecting sequencing methods |
| 488 |
* Mixed:: Using mixed charset input |
| 489 |
* Emacs:: Using Recode within Emacs |
| 490 |
* Debugging:: Debugging considerations |
| 491 |
|
| 492 |
|
| 493 |
File: recode.info, Node: Synopsis, Next: Requests, Prev: Invoking recode, Up: Invoking recode |
| 494 |
|
| 495 |
3.1 Synopsis of ‘recode’ call |
| 496 |
============================= |
| 497 |
|
| 498 |
The general format of the program call is one of: |
| 499 |
|
| 500 |
recode [OPTION]... [CHARSET | REQUEST [FILE]... ] |
| 501 |
|
| 502 |
Some calls are used only to obtain lists produced by Recode itself, |
| 503 |
without actually recoding any file. They are recognised through the |
| 504 |
usage of listing options, and these options decide what meaning should |
| 505 |
be given to an optional CHARSET parameter. *Note Listings::. |
| 506 |
|
| 507 |
In other calls, the first parameter (REQUEST) always explains which |
| 508 |
transformations are expected on the files. There are many variations to |
| 509 |
the aspect of this parameter. We will discuss more complex situations |
| 510 |
later (*note Requests::), but for many simple cases, this parameter |
| 511 |
merely looks like this(1): |
| 512 |
|
| 513 |
BEFORE..AFTER |
| 514 |
|
| 515 |
where BEFORE and AFTER each gives the name of a charset. Each FILE will |
| 516 |
be read assuming it is coded with charset BEFORE, it will be recoded |
| 517 |
over itself so to use the charset AFTER. If there is no FILE on the |
| 518 |
‘recode’ command, the program rather acts as a Unix filter and |
| 519 |
transforms standard input onto standard output. |
| 520 |
|
| 521 |
The capability of recoding many files at once is very convenient. |
| 522 |
For example, one could easily prepare a distribution from Latin-1 to |
| 523 |
MSDOS, this way: |
| 524 |
|
| 525 |
mkdir package |
| 526 |
cp -p Makefile *.[ch] package |
| 527 |
recode Latin-1..MSDOS package/* |
| 528 |
zoo ah package.zoo package/* |
| 529 |
rm -rf package |
| 530 |
|
| 531 |
(In this example, the non-mandatory ‘-p’ option to ‘cp’ is for |
| 532 |
preserving timestamps, and the ‘zoo’ program is an archiver from Rahul |
| 533 |
Dhesi which once was quite popular.) |
| 534 |
|
| 535 |
The filter operation is especially useful when the input files should |
| 536 |
not be altered. Let us make an example to illustrate this point. |
| 537 |
Suppose that someone has a file named ‘datum.txt’, which is almost a TeX |
| 538 |
file, except that diacriticised characters are written using Latin-1. |
| 539 |
To complete the recoding of the diacriticised characters _only_ and |
| 540 |
produce a file ‘datum.tex’, without destroying the original, one could |
| 541 |
do: |
| 542 |
|
| 543 |
cp -p datum.txt datum.tex |
| 544 |
recode -d l1..tex datum.tex |
| 545 |
|
| 546 |
However, using ‘recode’ as a filter will achieve the same goal more |
| 547 |
neatly: |
| 548 |
|
| 549 |
recode -d l1..tex <datum.txt >datum.tex |
| 550 |
|
| 551 |
This example also shows that ‘l1’ could be used instead of ‘Latin-1’; |
| 552 |
charset names often have such aliases. |
| 553 |
|
| 554 |
Recode has three modes are for when to set the exit status to |
| 555 |
non-zero: |
| 556 |
|
| 557 |
• The most lenient setting is activated with option ‘-f’, in which |
| 558 |
case only system errors or library mis-usage causes the exit status |
| 559 |
to be set. |
| 560 |
|
| 561 |
• By default, without ‘-f’ nor ‘-s’, Recode sets the exit status as |
| 562 |
above, and also in case of invalid or untranslatable input. It |
| 563 |
also tries (but not always succeed) to detect if output is going to |
| 564 |
be ambiguous at some later recode-back time. |
| 565 |
|
| 566 |
• The stricter setting is activated with ‘-s’, Recode then sets the |
| 567 |
exit status as above, or if input is not canonically coded (and it |
| 568 |
also prevents itself from _completing_ recoding tables for making |
| 569 |
the recoding reversible). |
| 570 |
|
| 571 |
---------- Footnotes ---------- |
| 572 |
|
| 573 |
(1) In previous versions of Recode, a single colon ‘:’ was used |
| 574 |
instead of the two dots ‘..’ for separating charsets, but this created |
| 575 |
problems, because colons are allowed in official charset names. |
| 576 |
|
| 577 |
|
| 578 |
File: recode.info, Node: Requests, Next: Listings, Prev: Synopsis, Up: Invoking recode |
| 579 |
|
| 580 |
3.2 The REQUEST parameter |
| 581 |
========================= |
| 582 |
|
| 583 |
In the case where the REQUEST is merely written as BEFORE..AFTER, then |
| 584 |
BEFORE and AFTER specify the start charset and the goal charset for the |
| 585 |
recoding. |
| 586 |
|
| 587 |
For Recode, charset names may contain any character, besides a comma, |
| 588 |
a forward slash, or two periods in a row. But in practice, charset |
| 589 |
names are currently limited to alphabetic letters (upper or lower case), |
| 590 |
digits, hyphens, underlines, periods, colons or round parentheses. |
| 591 |
|
| 592 |
The complete syntax for a valid REQUEST allows for unusual things, |
| 593 |
which might be surprising at first. (Do not pay too much attention to |
| 594 |
these facilities on first reading.) For example, REQUEST may also |
| 595 |
contain intermediate charsets, like in the following example: |
| 596 |
|
| 597 |
BEFORE..INTERIM1..INTERIM2..AFTER |
| 598 |
|
| 599 |
meaning that Recode should internally produce the INTERIM1 charset from |
| 600 |
the start charset, then work out of this INTERIM1 charset to internally |
| 601 |
produce INTERIM2, and from there towards the goal charset. In fact, |
| 602 |
Recode internally combines recipes and automatically uses interim |
| 603 |
charsets, when there is no direct recipe for transforming BEFORE into |
| 604 |
AFTER. But there might be many ways to do it. When many routes are |
| 605 |
possible, the above “chaining” syntax may be used to more precisely |
| 606 |
force the program towards a particular route, which it might not have |
| 607 |
naturally selected otherwise. On the other hand, because Recode tries |
| 608 |
to choose good routes, chaining is only needed to achieve some rare, |
| 609 |
unusual effects. |
| 610 |
|
| 611 |
Moreover, many such requests (sub-requests, more precisely) may be |
| 612 |
separated with commas (but no spaces at all), indicating a sequence of |
| 613 |
recodings, where the output of one has to serve as the input of the |
| 614 |
following one. For example, the two following requests are equivalent: |
| 615 |
|
| 616 |
BEFORE..INTERIM1..INTERIM2..AFTER |
| 617 |
BEFORE..INTERIM1,INTERIM1..INTERIM2,INTERIM2..AFTER |
| 618 |
|
| 619 |
In this example, the charset input for any recoding sub-request is |
| 620 |
identical to the charset output by the preceding sub-request. But it |
| 621 |
does not have to be so in the general case. One might wonder what would |
| 622 |
be the meaning of declaring the charset input for a recoding sub-request |
| 623 |
of being of different nature than the charset output by a preceding |
| 624 |
sub-request, when recodings are chained in this way. Such a strange |
| 625 |
usage might have a meaning and be useful for the Recode expert, but they |
| 626 |
are quite uncommon in practice. |
| 627 |
|
| 628 |
More useful is the distinction between the concept of charset, and |
| 629 |
the concept of surfaces. An encoded charset is represented by: |
| 630 |
|
| 631 |
PURE-CHARSET/SURFACE1/SURFACE2... |
| 632 |
|
| 633 |
using slashes to introduce surfaces, if any. The order of application |
| 634 |
of surfaces is usually important, they cannot be freely commuted. In |
| 635 |
the given example, SURFACE1 is first applied over the PURE-CHARSET, then |
| 636 |
SURFACE2 is applied over the result. Given this request: |
| 637 |
|
| 638 |
BEFORE/SURFACE1/SURFACE2..AFTER/SURFACE3 |
| 639 |
|
| 640 |
Recode will understand that the input files should have SURFACE2 removed |
| 641 |
first (because it was applied last), then SURFACE1 should be removed. |
| 642 |
The next step will be to translate the codes from charset BEFORE to |
| 643 |
charset AFTER, prior to applying SURFACE3 over the result. |
| 644 |
|
| 645 |
Some charsets have one or more _implied_ surfaces. In this case, the |
| 646 |
implied surfaces are automatically handled merely by naming the charset, |
| 647 |
without any explicit surface to qualify it. Let's take an example to |
| 648 |
illustrate this feature. The request ‘pc..l1’ will indeed decode MS-DOS |
| 649 |
end of lines prior to converting IBM-PC codes to Latin-1, because ‘pc’ |
| 650 |
is the name of a charset(1) which has ‘CR-LF’ for its usual surface. |
| 651 |
The request ‘pc/..l1’ will _not_ decode end of lines, since the slash |
| 652 |
introduces surfaces, and even if the surface list is empty, it |
| 653 |
effectively defeats the automatic removal of surfaces for this charset. |
| 654 |
So, empty surfaces are useful, indeed! |
| 655 |
|
| 656 |
Both charsets and surfaces may have predefined alternate names, or |
| 657 |
aliases. However, and this is rather important to understand, implied |
| 658 |
surfaces are attached to individual aliases rather than on genuine |
| 659 |
charsets. Consequently, the official charset name and all of its |
| 660 |
aliases do not necessarily share the same implied surfaces. The charset |
| 661 |
and all its aliases may each have its own different set of implied |
| 662 |
surfaces. |
| 663 |
|
| 664 |
Charset names, surface names, or their aliases may always be |
| 665 |
abbreviated to any unambiguous prefix. Internally in Recode, |
| 666 |
disambiguating tables are kept separate for charset names and surface |
| 667 |
names. |
| 668 |
|
| 669 |
While recognising a charset name or a surface name (or aliases |
| 670 |
thereof), Recode ignores all characters besides letters and digits, so |
| 671 |
for example, the hyphens and underlines being part of an official |
| 672 |
charset name may safely be omitted (no need to un-confuse them!). There |
| 673 |
is also no distinction between upper and lower case for charset or |
| 674 |
surface names. |
| 675 |
|
| 676 |
One of the BEFORE or AFTER keywords may be omitted. If the double |
| 677 |
dot separator is omitted too, then the charset is interpreted as the |
| 678 |
BEFORE charset.(2) |
| 679 |
|
| 680 |
When a charset name is omitted or left empty, the value of the |
| 681 |
‘DEFAULT_CHARSET’ variable in the environment is used instead. If this |
| 682 |
variable is not defined, the Recode library uses the current locale's |
| 683 |
encoding. On POSIX systems, this depends on the first non-empty value |
| 684 |
among the environment variables ‘LC_ALL’, ‘LC_CTYPE’, and ‘LANG’, and |
| 685 |
can be determined through the command ‘locale charmap’. If the current |
| 686 |
locale's encoding may not be resolved, then Recode presumes ‘ASCII’. |
| 687 |
|
| 688 |
If the charset name is omitted but followed by surfaces, the surfaces |
| 689 |
then qualify the usual or default charset. For example, the request |
| 690 |
‘../x’ is sufficient for applying an hexadecimal surface to the input |
| 691 |
text(3). |
| 692 |
|
| 693 |
The allowable values for BEFORE or AFTER charsets, and various |
| 694 |
surfaces, are described in the remainder of this document. |
| 695 |
|
| 696 |
---------- Footnotes ---------- |
| 697 |
|
| 698 |
(1) More precisely, ‘pc’ is an alias for the charset ‘IBM-PC’. |
| 699 |
|
| 700 |
(2) Both BEFORE and AFTER may be omitted, in which case the double |
| 701 |
dot separator is mandatory. This is not very useful, as the recoding |
| 702 |
reduces to a mere copy in that case. |
| 703 |
|
| 704 |
(3) MS-DOS is one of those systems for which the default charset has |
| 705 |
implied surfaces, ‘CR-LF’ here. Such surfaces are automatically removed |
| 706 |
or applied whenever the default charset is read or written, exactly as |
| 707 |
it would go for any other charset. In the example above, on such |
| 708 |
systems, the hexadecimal surface would then _replace_ the implied |
| 709 |
surfaces. For _adding_ an hexadecimal surface without removing any, one |
| 710 |
should write the request as ‘/../x’. |
| 711 |
|
| 712 |
|
| 713 |
File: recode.info, Node: Listings, Next: Recoding, Prev: Requests, Up: Invoking recode |
| 714 |
|
| 715 |
3.3 Asking for various lists |
| 716 |
============================ |
| 717 |
|
| 718 |
Many options control listing output generated by Recode itself, they are |
| 719 |
not meant to accompany actual file recodings. These options are: |
| 720 |
|
| 721 |
‘--version’ |
| 722 |
The program merely prints its version numbers on standard output, |
| 723 |
and exits without doing anything else. |
| 724 |
|
| 725 |
‘--help’ |
| 726 |
The program merely prints a page of help on standard output, and |
| 727 |
exits without doing any recoding. |
| 728 |
|
| 729 |
‘-C’ |
| 730 |
‘--copyright’ |
| 731 |
Given this option, all other parameters and options are ignored. |
| 732 |
The program prints briefly the copyright and copying conditions. |
| 733 |
See the file ‘COPYING’ in the distribution for full statement of |
| 734 |
the Copyright and copying conditions. |
| 735 |
|
| 736 |
‘-h[LANGUAGE/][NAME]’ |
| 737 |
‘--header[=[LANGUAGE/][NAME]]’ |
| 738 |
Instead of recoding files, Recode writes a LANGUAGE source file on |
| 739 |
standard output and exits. This source is meant to be included in |
| 740 |
a regular program written in the same programming LANGUAGE: its |
| 741 |
purpose is to declare and initialise an array, named NAME, which |
| 742 |
represents the requested recoding. The only acceptable values for |
| 743 |
LANGUAGE are ‘c’ or ‘perl’, and may may be abbreviated. If |
| 744 |
LANGUAGE is not specified, ‘c’ is assumed. If NAME is not |
| 745 |
specified, then it defaults to ‘BEFORE_AFTER’. Strings BEFORE and |
| 746 |
AFTER are cleaned before being used according to the syntax of |
| 747 |
LANGUAGE. |
| 748 |
|
| 749 |
Even if Recode tries its best, this option does not always succeed |
| 750 |
in producing the requested source table, it then prints ‘Recoding |
| 751 |
is too complex for a mere table’. It will succeed however, |
| 752 |
provided the recoding can be internally represented by only one |
| 753 |
step after the optimisation phase, and if this merged step conveys |
| 754 |
a one-to-one or a one-to-many explicit table. To increase the |
| 755 |
probability that this happens, ‘iconv’ initialisation is currently |
| 756 |
inhibited whenever this option is used. Also, when attempting to |
| 757 |
produce sources tables, Recode relaxes its checking a tiny bit: it |
| 758 |
ignores the algorithmic part of some tabular recodings, it also |
| 759 |
avoids the processing of implied surfaces. But this is all fairly |
| 760 |
technical. Better try and see! |
| 761 |
|
| 762 |
Most tables are produced using decimal numbers to refer to |
| 763 |
character values(1). Yet, users who know all Recode tricks and |
| 764 |
stunts could indeed force octal or hexadecimal output for the table |
| 765 |
contents. For example: |
| 766 |
|
| 767 |
recode ibm297/test8..cp1252/x < /dev/null |
| 768 |
|
| 769 |
produces a sequence of hexadecimal values which represent a |
| 770 |
conversion table from ‘IBM297’ to ‘CP1252’. |
| 771 |
|
| 772 |
Beware that other options might affect the produced source tables, |
| 773 |
these are: ‘-d’, ‘-g’ and, particularly, ‘-s’. |
| 774 |
|
| 775 |
‘-k PAIRS’ |
| 776 |
‘--known=PAIRS’ |
| 777 |
This particular option is meant to help identifying an unknown |
| 778 |
charset, using as hints some already identified characters of the |
| 779 |
charset. Some examples will help introducing the idea. |
| 780 |
|
| 781 |
Let's presume here that Recode is run in a UTF-8 locale, and that |
| 782 |
‘DEFAULT_CHARSET’ is unset in the environment. Suppose you have |
| 783 |
guessed that code 130 (decimal) of the unknown charset represents a |
| 784 |
lower case ‘e’ with an acute accent. That is to say that this code |
| 785 |
should map to code 233 (decimal) in the usual charset. By |
| 786 |
executing: |
| 787 |
|
| 788 |
recode -k 130:233 |
| 789 |
|
| 790 |
you should obtain a listing similar to: |
| 791 |
|
| 792 |
AtariST |
| 793 |
CWI cp-hu CWI-2 |
| 794 |
IBM437/CR-LF 437/CR-LF CP437/CR-LF |
| 795 |
IBM850/CR-LF 850/CR-LF CP850/CR-LF |
| 796 |
IBM851/CR-LF 851/CR-LF CP851/CR-LF |
| 797 |
IBM852/CR-LF 852/CR-LF CP852/CR-LF pcl2 pclatin2 |
| 798 |
IBM857/CR-LF 857/CR-LF CP857/CR-LF |
| 799 |
IBM860/CR-LF 860/CR-LF CP860/CR-LF |
| 800 |
IBM861/CR-LF 861/CR-LF CP861/CR-LF cp-is |
| 801 |
IBM863/CR-LF 863/CR-LF CP863/CR-LF |
| 802 |
IBM865/CR-LF 865/CR-LF CP865/CR-LF |
| 803 |
|
| 804 |
You can give more than one clue at once, to restrict the list |
| 805 |
further. Suppose you have _also_ guessed that code 211 of the |
| 806 |
unknown charset represents an upper case ‘E’ with diaeresis, that |
| 807 |
is, code 203 in the usual charset. By requesting: |
| 808 |
|
| 809 |
recode -k 130:233,211:203 |
| 810 |
|
| 811 |
you should obtain: |
| 812 |
|
| 813 |
IBM850/CR-LF 850/CR-LF CP850/CR-LF |
| 814 |
IBM852/CR-LF 852/CR-LF CP852/CR-LF pcl2 pclatin2 |
| 815 |
IBM857/CR-LF 857/CR-LF CP857/CR-LF |
| 816 |
|
| 817 |
The usual charset may be overridden by specifying one non-option |
| 818 |
argument. For example, to request the list of charsets for which |
| 819 |
code 130 maps to code 142 for the Macintosh, you may ask: |
| 820 |
|
| 821 |
recode -k 130:142 mac |
| 822 |
|
| 823 |
and get: |
| 824 |
|
| 825 |
AtariST |
| 826 |
CWI cp-hu CWI-2 |
| 827 |
IBM437/CR-LF 437/CR-LF CP437/CR-LF |
| 828 |
IBM850/CR-LF 850/CR-LF CP850/CR-LF |
| 829 |
IBM851/CR-LF 851/CR-LF CP851/CR-LF |
| 830 |
IBM852/CR-LF 852/CR-LF CP852/CR-LF pcl2 pclatin2 |
| 831 |
IBM857/CR-LF 857/CR-LF CP857/CR-LF |
| 832 |
IBM860/CR-LF 860/CR-LF CP860/CR-LF |
| 833 |
IBM861/CR-LF 861/CR-LF CP861/CR-LF cp-is |
| 834 |
IBM863/CR-LF 863/CR-LF CP863/CR-LF |
| 835 |
IBM865/CR-LF 865/CR-LF CP865/CR-LF |
| 836 |
|
| 837 |
which, of course, is identical to the result of the first example, |
| 838 |
since the code 142 for the Macintosh is a small ‘e’ with acute. |
| 839 |
|
| 840 |
More formally, option ‘-k’ lists all possible _before_ charsets for |
| 841 |
the _after_ charset given as the sole non-option argument to |
| 842 |
‘recode’, but subject to restrictions given in PAIRS. If there is |
| 843 |
no non-option argument, the _after_ charset is taken to be the |
| 844 |
default charset for this ‘recode’. |
| 845 |
|
| 846 |
The restrictions are given as a comma separated list of pairs, each |
| 847 |
pair consisting of two numbers separated by a colon. The numbers |
| 848 |
are taken as decimal when the initial digit is between ‘1’ and ‘9’; |
| 849 |
‘0x’ starts an hexadecimal number, or else ‘0’ starts an octal |
| 850 |
number. The first number is a code in any _before_ charset, while |
| 851 |
the second number is a code in the specified _after_ charset. If |
| 852 |
the first number would not be transformed into the second number by |
| 853 |
recoding from some _before_ charset to the _after_ charset, then |
| 854 |
this _before_ charset is rejected. A _before_ charset is listed |
| 855 |
only if it is not rejected by any pair. The program will only test |
| 856 |
those _before_ charsets having a tabular style internal description |
| 857 |
(*note Tabular::), so should be the selected _after_ charset. |
| 858 |
|
| 859 |
The produced list is in fact a subset of the list produced by the |
| 860 |
option ‘-l’. As for option ‘-l’, the non-option argument is |
| 861 |
interpreted as a charset name, possibly abbreviated to any non |
| 862 |
ambiguous prefix. |
| 863 |
|
| 864 |
‘-l[FORMAT]’ |
| 865 |
‘--list[=FORMAT]’ |
| 866 |
This option asks for information about all charsets, or about one |
| 867 |
particular charset. No file will be recoded. |
| 868 |
|
| 869 |
If there is no non-option arguments, Recode ignores the FORMAT |
| 870 |
value of the option, it writes a sorted list of charset names on |
| 871 |
standard output, one per line. When a charset name have aliases or |
| 872 |
synonyms, they follow the true charset name on its line, sorted |
| 873 |
from left to right. Each charset or alias is followed by its |
| 874 |
implied surfaces, if any. This list is over two hundred lines. It |
| 875 |
is best used with ‘grep -i’, as in: |
| 876 |
|
| 877 |
recode -l | grep -i greek |
| 878 |
|
| 879 |
Within a collection of names for a single charset, the Recode |
| 880 |
library distinguishes one of them as being the genuine charset |
| 881 |
name, while the others are said to be aliases. The list normally |
| 882 |
integrates all charsets from the external ‘iconv’ library, unless |
| 883 |
this is defeated through options like ‘--ignore=:iconv:’ or ‘-x:’. |
| 884 |
The portable ‘libiconv’ library relates its own aliases of a same |
| 885 |
charset, and for a given set of aliases, if none of them are known |
| 886 |
to Recode already, then Recode will pick one as being the genuine |
| 887 |
charset. The ‘iconv’ library within GNU ‘libc’ makes all aliases |
| 888 |
appear as different charsets, and each will be presented as a |
| 889 |
charset by Recode, unless it is known otherwise. |
| 890 |
|
| 891 |
There might be one non-option argument, in which case it is |
| 892 |
interpreted as a charset name, possibly abbreviated to any non |
| 893 |
ambiguous prefix. This particular usage of the ‘-l’ option is |
| 894 |
obeyed _only_ for charsets having a tabular style internal |
| 895 |
description (*note Tabular::). Even if most charsets have this |
| 896 |
property, some do not, and the option ‘-l’ cannot be used to detail |
| 897 |
these particular charsets. For knowing if a particular charset can |
| 898 |
be listed this way, you should merely try and see if this works. |
| 899 |
The FORMAT value of the option is a keyword from the following |
| 900 |
list. Keywords may be abbreviated by dropping suffix letters, and |
| 901 |
even reduced to the first letter only: |
| 902 |
|
| 903 |
‘decimal’ |
| 904 |
This format asks for the production on standard output of a |
| 905 |
concise tabular display of the charset, in which character |
| 906 |
code values are expressed in decimal. |
| 907 |
|
| 908 |
‘octal’ |
| 909 |
This format uses octal instead of decimal in the concise |
| 910 |
tabular display of the charset. |
| 911 |
|
| 912 |
‘hexadecimal’ |
| 913 |
This format uses hexadecimal instead of decimal in the concise |
| 914 |
tabular display of the charset. |
| 915 |
|
| 916 |
‘full’ |
| 917 |
This format requests an extensive display of the charset on |
| 918 |
standard output, using one line per character showing its |
| 919 |
decimal, hexadecimal, octal and ‘UCS-2’ code values, and also |
| 920 |
a descriptive comment which should be the 10646 name for the |
| 921 |
character. |
| 922 |
|
| 923 |
The descriptive comment is given in English and ASCII, yet if |
| 924 |
the English description is not available but a French one is, |
| 925 |
then the French description is given instead, using Latin-1. |
| 926 |
However, if the ‘LC_MESSAGES’ environment variable begins with |
| 927 |
the letters ‘fr’, then listing preference goes to French when |
| 928 |
both descriptions are available. |
| 929 |
|
| 930 |
When option ‘-l’ is used together with a CHARSET argument, the |
| 931 |
FORMAT defaults to ‘decimal’. |
| 932 |
|
| 933 |
‘-T’ |
| 934 |
‘--find-subsets’ |
| 935 |
This option is a maintainer tool for evaluating the redundancy of |
| 936 |
those charsets, in Recode, which are internally represented by an |
| 937 |
‘UCS-2’ data table. After the listing has been produced, the |
| 938 |
program exits without doing any recoding. The output is meant to |
| 939 |
be sorted, like this: ‘recode -T | sort’. The option triggers |
| 940 |
Recode into comparing all pairs of charsets, seeking those which |
| 941 |
are subsets of others. The concept and results are better |
| 942 |
explained through a few examples. Consider these three sample |
| 943 |
lines from ‘-T’ output: |
| 944 |
|
| 945 |
[ 0] IBM891 == IBM903 |
| 946 |
[ 1] IBM1004 < CP1252 |
| 947 |
[ 12] INVARIANT < CSA_Z243.4-1985-1 |
| 948 |
|
| 949 |
The first line means that ‘IBM891’ and ‘IBM903’ are completely |
| 950 |
identical as far as Recode is concerned, so one is fully redundant |
| 951 |
to the other. The second line says that ‘IBM1004’ is wholly |
| 952 |
contained within ‘CP1252’, yet there is a single character which is |
| 953 |
in ‘CP1252’ without being in ‘IBM1004’. The third line says that |
| 954 |
‘INVARIANT’ is wholly contained within ‘CSA_Z243.4-1985-1’, but |
| 955 |
twelve characters are in ‘CSA_Z243.4-1985-1’ without being in |
| 956 |
‘INVARIANT’. The whole output might most probably be reduced and |
| 957 |
made more significant through a transitivity study. |
| 958 |
|
| 959 |
---------- Footnotes ---------- |
| 960 |
|
| 961 |
(1) The author of Recode by far prefer expressing numbers in decimal |
| 962 |
than octal or hexadecimal, as he considers that the current state of |
| 963 |
technology should not force users anymore in such strange things. But |
| 964 |
Unicode people see things differently, to the point Recode cannot escape |
| 965 |
being tainted with some hexadecimal. |
| 966 |
|
| 967 |
|
| 968 |
File: recode.info, Node: Recoding, Next: Reversibility, Prev: Listings, Up: Invoking recode |
| 969 |
|
| 970 |
3.4 Controlling how files are recoded |
| 971 |
===================================== |
| 972 |
|
| 973 |
The following options have the purpose of giving the user some fine |
| 974 |
grain control over the recoding operation themselves. |
| 975 |
|
| 976 |
‘-c’ |
| 977 |
‘--colons’ |
| 978 |
With ‘Texte’ Easy French conventions, use the column ‘:’ instead of |
| 979 |
the double-quote ‘"’ for marking diaeresis. *Note Texte::. |
| 980 |
|
| 981 |
‘-g’ |
| 982 |
‘--graphics’ |
| 983 |
This option is only meaningful while getting _out_ of the ‘IBM-PC’ |
| 984 |
charset. In this charset, characters 176 to 223 are used for |
| 985 |
constructing rulers and boxes, using simple or double horizontal or |
| 986 |
vertical lines. This option forces the automatic selection of |
| 987 |
ASCII characters for approximating these rulers and boxes, at cost |
| 988 |
of making the transformation irreversible. Option ‘-g’ implies |
| 989 |
‘-f’. |
| 990 |
|
| 991 |
‘-t’ |
| 992 |
‘--touch’ |
| 993 |
The _touch_ option is meaningful only when files are recoded over |
| 994 |
themselves. Without it, the time-stamps associated with files are |
| 995 |
preserved, to reflect the fact that changing the code of a file |
| 996 |
does not really alter its informational contents. When the user |
| 997 |
wants the recoded files to be time-stamped at the recoding time, |
| 998 |
this option inhibits the automatic protection of the time-stamps. |
| 999 |
|
| 1000 |
‘-v’ |
| 1001 |
‘--verbose’ |
| 1002 |
Before doing any recoding, the program will first print on the |
| 1003 |
‘stderr’ stream the list of all intermediate charsets planned for |
| 1004 |
recoding, starting with the BEFORE charset and ending with the |
| 1005 |
AFTER charset. It also prints an indication of the recoding |
| 1006 |
quality, as one of the word ‘reversible’, ‘one to one’, ‘one to |
| 1007 |
many’, ‘many to one’ or ‘many to many’. |
| 1008 |
|
| 1009 |
This information will appear once or twice. It is shown a second |
| 1010 |
time only when the optimisation and step merging phase succeeds in |
| 1011 |
replacing many single steps by a new one. |
| 1012 |
|
| 1013 |
This option also has a second effect. The program will print on |
| 1014 |
‘stderr’ one message per recoded FILE, so as to keep the user |
| 1015 |
informed of the progress of its command. |
| 1016 |
|
| 1017 |
An easy way to know beforehand the sequence or quality of a |
| 1018 |
recoding is by using the command such as: |
| 1019 |
|
| 1020 |
recode -v BEFORE..AFTER < /dev/null |
| 1021 |
|
| 1022 |
using the fact that, in Recode, an empty input file produces an |
| 1023 |
empty output file. |
| 1024 |
|
| 1025 |
‘-x CHARSET’ |
| 1026 |
‘--ignore=CHARSET’ |
| 1027 |
This option tells the program to ignore any recoding path through |
| 1028 |
the specified CHARSET, so disabling any single step using this |
| 1029 |
charset as a start or end point. This may be used when the user |
| 1030 |
wants to force Recode into using an alternate recoding path (yet |
| 1031 |
using chained requests offers a finer control, *note Requests::). |
| 1032 |
|
| 1033 |
CHARSET may be abbreviated to any unambiguous prefix. |
| 1034 |
|
| 1035 |
|
| 1036 |
File: recode.info, Node: Reversibility, Next: Sequencing, Prev: Recoding, Up: Invoking recode |
| 1037 |
|
| 1038 |
3.5 Reversibility issues |
| 1039 |
======================== |
| 1040 |
|
| 1041 |
The following options are somewhat related to reversibility issues: |
| 1042 |
|
| 1043 |
‘-f’ |
| 1044 |
‘--force’ |
| 1045 |
With this option, irreversible or otherwise erroneous recodings are |
| 1046 |
run to completion, and ‘recode’ does not exit with a non-zero |
| 1047 |
status if it would be only because irreversibility matters. *Note |
| 1048 |
Reversibility::. |
| 1049 |
|
| 1050 |
Without this option, Recode tries to protect you against recoding a |
| 1051 |
file irreversibly over itself(1). Whenever an irreversible |
| 1052 |
recoding is met, or any other recoding error, ‘recode’ produces a |
| 1053 |
warning on standard error. The current input file does not get |
| 1054 |
replaced by its recoded version, and ‘recode’ then proceeds with |
| 1055 |
the recoding of the next file. |
| 1056 |
|
| 1057 |
When the program is merely used as a filter, standard output will |
| 1058 |
have received a partially recoded copy of standard input, up to the |
| 1059 |
first error point. After all recodings have been done or |
| 1060 |
attempted, and if some recoding has been aborted, ‘recode’ exits |
| 1061 |
with a non-zero status. |
| 1062 |
|
| 1063 |
‘-q’ |
| 1064 |
‘--quiet’ |
| 1065 |
‘--silent’ |
| 1066 |
This option has the sole purpose of inhibiting warning messages |
| 1067 |
about irreversible recodings, and other such diagnostics. It has |
| 1068 |
no other effect, in particular, it does _not_ prevent recodings to |
| 1069 |
be aborted or ‘recode’ to return a non-zero exit status when |
| 1070 |
irreversible recodings are met. |
| 1071 |
|
| 1072 |
This option is set automatically for the children processes, when |
| 1073 |
recode splits itself in many collaborating copies. Doing so, the |
| 1074 |
diagnostic is issued only once by the parent. See option ‘-p’. |
| 1075 |
|
| 1076 |
‘-s’ |
| 1077 |
‘--strict’ |
| 1078 |
By using this option, the user requests that Recode be very strict |
| 1079 |
while recoding a file, merely losing in the transformation any |
| 1080 |
character which is not explicitly mapped from a charset to another. |
| 1081 |
Such a loss is not reversible and so, will bring Recode to fail, |
| 1082 |
unless the option ‘-f’ is also given as a kind of counter-measure. |
| 1083 |
|
| 1084 |
Using ‘-s’ without ‘-f’ might render Recode very susceptible to the |
| 1085 |
slighest file abnormalities. Despite the fact that it might be |
| 1086 |
irritating to some users, such paranoia is sometimes wanted and |
| 1087 |
useful. |
| 1088 |
|
| 1089 |
Even if Recode tries hard to keep the recodings reversible, you |
| 1090 |
should not develop an unconditional confidence in its ability to do so. |
| 1091 |
You _ought_ to keep only reasonable expectations about reverse |
| 1092 |
recodings. In particular, consider: |
| 1093 |
|
| 1094 |
• Most transformations are fully reversible for all inputs, but lose |
| 1095 |
this property whenever ‘-s’ is specified. |
| 1096 |
|
| 1097 |
• A few transformations are not meant to be reversible, by design. |
| 1098 |
|
| 1099 |
• Reversibility sometimes depends on actual file contents and cannot |
| 1100 |
be ascertained beforehand, without reading the file. |
| 1101 |
|
| 1102 |
• Reversibility is never absolute across successive versions of this |
| 1103 |
program. Even correcting a small bug in a mapping could induce |
| 1104 |
slight discrepancies later. |
| 1105 |
|
| 1106 |
• Reversibility is easily lost by merging. This is best explained |
| 1107 |
through an example. If you reversibly recode a file from charset A |
| 1108 |
to charset B, then you reversibly recode the result from charset B |
| 1109 |
to charset C, you cannot expect to recover the original file by |
| 1110 |
merely recoding from charset C directly to charset A. You will |
| 1111 |
instead have to recode from charset C back to charset B, and only |
| 1112 |
then from charset B to charset A. |
| 1113 |
|
| 1114 |
• Faulty files create a particular problem. Consider an example, |
| 1115 |
recoding from ‘IBM-PC’ to ‘Latin-1’. End of lines are represented |
| 1116 |
as ‘\r\n’ in ‘IBM-PC’ and as ‘\n’ in ‘Latin-1’. There is no way by |
| 1117 |
which a faulty ‘IBM-PC’ file containing a ‘\n’ not preceded by ‘\r’ |
| 1118 |
be translated into a ‘Latin-1’ file, and then back. |
| 1119 |
|
| 1120 |
• There is another difficulty arising from code equivalences. For |
| 1121 |
example, in a ‘LaTeX’ charset file, the string ‘\^\i{}’ could be |
| 1122 |
recoded back and forth through another charset and become ‘\^{\i}’. |
| 1123 |
Even if the resulting file is equivalent to the original one, it is |
| 1124 |
not identical. |
| 1125 |
|
| 1126 |
Unless option ‘-s’ is used, Recode automatically tries to fill |
| 1127 |
mappings with invented correspondences, often making them fully |
| 1128 |
reversible. This filling is not made at random. The algorithm tries to |
| 1129 |
stick to the identity mapping and, when this is not possible, it prefers |
| 1130 |
generating many small permutation cycles, each involving only a few |
| 1131 |
codes. |
| 1132 |
|
| 1133 |
For example, here is how ‘IBM-PC’ code 186 gets translated to |
| 1134 |
‘control-U’ in ‘Latin-1’. ‘Control-U’ is 21. Code 21 is the ‘IBM-PC’ |
| 1135 |
section sign, which is 167 in ‘Latin-1’. Recode cannot reciprocate 167 |
| 1136 |
to 21, because 167 is the masculine ordinal indicator within ‘IBM-PC’, |
| 1137 |
which is 186 in ‘Latin-1’. Code 186 within ‘IBM-PC’ has no ‘Latin-1’ |
| 1138 |
equivalent; by assigning it back to 21, Recode closes this short |
| 1139 |
permutation loop. |
| 1140 |
|
| 1141 |
As a consequence of this map filling, Recode may sometimes produce |
| 1142 |
_funny_ characters. They may look annoying, they are nevertheless |
| 1143 |
helpful when one changes his (her) mind and wants to revert to the prior |
| 1144 |
recoding. If you cannot stand these, use option ‘-s’, which asks for a |
| 1145 |
very strict recoding. |
| 1146 |
|
| 1147 |
This map filling sometimes has a few surprising consequences, which |
| 1148 |
some users wrongly interpreted as bugs. Here are two examples. |
| 1149 |
|
| 1150 |
1. In some cases, Recode seems to copy a file without recoding it. |
| 1151 |
But in fact, it does. Consider a request: |
| 1152 |
|
| 1153 |
recode l1..us < File-Latin1 > File-ASCII |
| 1154 |
cmp File-Latin1 File-ASCII |
| 1155 |
|
| 1156 |
then ‘cmp’ will not report any difference. This is quite normal. |
| 1157 |
‘Latin-1’ gets correctly recoded to ASCII for charsets |
| 1158 |
commonalities (which are the first 128 characters, in this case). |
| 1159 |
The remaining last 128 ‘Latin-1’ characters have no ASCII |
| 1160 |
correspondent. Instead of losing them, Recode elects to map them |
| 1161 |
to unspecified characters of ASCII, so making the recoding |
| 1162 |
reversible. The simplest way of achieving this is merely to keep |
| 1163 |
those last 128 characters unchanged. The overall effect is copying |
| 1164 |
the file verbatim. |
| 1165 |
|
| 1166 |
If you feel this behaviour is too generous and if you do not wish |
| 1167 |
to care about reversibility, simply use option ‘-s’. By doing so, |
| 1168 |
Recode will strictly map only those ‘Latin-1’ characters which have |
| 1169 |
an ASCII equivalent, and will merely drop those which do not. |
| 1170 |
Then, there is more chance that you will observe a difference |
| 1171 |
between the input and the output file. |
| 1172 |
|
| 1173 |
2. Recoding the wrong way could sometimes give the false impression |
| 1174 |
that recoding has _almost_ been done properly. Consider the |
| 1175 |
requests: |
| 1176 |
|
| 1177 |
recode 437..l1 < File-Latin1 > Temp1 |
| 1178 |
recode 437..l1 < Temp1 > Temp2 |
| 1179 |
|
| 1180 |
so declaring wrongly ‘File-Latin1’ to be an IBM-PC file, and |
| 1181 |
recoding to ‘Latin-1’. This is surely ill defined and not |
| 1182 |
meaningful. Yet, if you repeat this step a second time, you might |
| 1183 |
notice that many (not all) characters in ‘Temp2’ are identical to |
| 1184 |
those in ‘File-Latin1’. Sometimes, people try to discover how |
| 1185 |
Recode works by experimenting a little at random, rather than |
| 1186 |
reading and understanding the documentation; results such as this |
| 1187 |
are surely confusing, as they provide those people with a false |
| 1188 |
feeling that they understood something. |
| 1189 |
|
| 1190 |
Reversible codings have this property that, if applied several |
| 1191 |
times in the same direction, they will eventually bring any |
| 1192 |
character back to its original value. Since Recode seeks small |
| 1193 |
permutation cycles when creating reversible codings, besides |
| 1194 |
characters unchanged by the recoding, most permutation cycles will |
| 1195 |
be of length 2, and fewer of length 3, etc. So, it is just |
| 1196 |
expectable that applying the recoding twice in the same direction |
| 1197 |
will recover most characters, but will fail to recover those |
| 1198 |
participating in permutation cycles of length 3. On the other end, |
| 1199 |
recoding six times in the same direction would recover all |
| 1200 |
characters in cycles of length 1, 2, 3 or 6. |
| 1201 |
|
| 1202 |
---------- Footnotes ---------- |
| 1203 |
|
| 1204 |
(1) There are still some cases of ambiguous output which are rather |
| 1205 |
difficult to detect, and for which the protection is not active. |
| 1206 |
|
| 1207 |
|
| 1208 |
File: recode.info, Node: Sequencing, Next: Mixed, Prev: Reversibility, Up: Invoking recode |
| 1209 |
|
| 1210 |
3.6 Selecting sequencing methods |
| 1211 |
================================ |
| 1212 |
|
| 1213 |
Recode can split itself into multiple parallel processes when it is |
| 1214 |
discovered that many passes are needed to comply with the REQUEST. For |
| 1215 |
example, suppose that four elementary steps were selected at recoding |
| 1216 |
path optimisation time. Then Recode will split itself into four |
| 1217 |
different interconnected tasks, logically equivalent to: |
| 1218 |
|
| 1219 |
STEP1 <INPUT | STEP2 | STEP3 | STEP4 >OUTPUT |
| 1220 |
|
| 1221 |
On systems where the pipes method is not available, the steps are |
| 1222 |
performed in series. |
| 1223 |
|
| 1224 |
‘--sequence=memory’ |
| 1225 |
When the recoding requires a combination of two or more elementary |
| 1226 |
recoding steps, this option forces many passes over the data, using |
| 1227 |
in-memory buffers to hold all intermediate results. If this option |
| 1228 |
is selected in filter mode, that is, when the program reads |
| 1229 |
standard input and writes standard output, it might take longer for |
| 1230 |
programs further down the pipe chain to start receiving some |
| 1231 |
recoded data. |
| 1232 |
|
| 1233 |
‘-p’ |
| 1234 |
‘--sequence=pipe’ |
| 1235 |
When the recoding requires a combination of two or more elementary |
| 1236 |
recoding steps, this option forces the program to fork itself into |
| 1237 |
a few copies interconnected with pipes, using the ‘pipe(2)’ system |
| 1238 |
call. All copies of the program operate in parallel. This is the |
| 1239 |
default behaviour in filter mode. If this option is used when |
| 1240 |
files are recoded over themselves, this should also save disk space |
| 1241 |
because some temporary files might not be needed, at the cost of |
| 1242 |
more system overhead. |
| 1243 |
|
| 1244 |
‘-i’ |
| 1245 |
‘--sequence=files’ |
| 1246 |
This option is accepted for backwards compatibility, and acts like |
| 1247 |
‘--sequence=memory’. |
| 1248 |
|
| 1249 |
|
| 1250 |
File: recode.info, Node: Mixed, Next: Emacs, Prev: Sequencing, Up: Invoking recode |
| 1251 |
|
| 1252 |
3.7 Using mixed charset input |
| 1253 |
============================= |
| 1254 |
|
| 1255 |
In real life and practice, textual files are often made up of many |
| 1256 |
charsets at once. Some parts of the file encode one charset, while |
| 1257 |
other parts encode another charset, and so forth. Usually, a file does |
| 1258 |
not toggle between more than two or three charsets. The means to |
| 1259 |
distinguish which charsets are encoded at various places is not always |
| 1260 |
available. Recode is able to handle only a few simple cases of mixed |
| 1261 |
input. |
| 1262 |
|
| 1263 |
The default Recode behaviour is to expect pure charset files, to be |
| 1264 |
recoded as other pure charset files. However, the following options |
| 1265 |
allow for a few precise kinds of mixed charset files. |
| 1266 |
|
| 1267 |
‘-d’ |
| 1268 |
‘--diacritics’ |
| 1269 |
While converting to or from one of ‘HTML’, ‘LaTeX’ or ‘BibTeX’ |
| 1270 |
charset, limit conversion to some subset of all characters. For |
| 1271 |
‘HTML’, limit conversion to the subset of all non-ASCII characters. |
| 1272 |
For ‘LaTeX’ or ‘BibTeX’, limit conversion to the subset of all |
| 1273 |
non-English letters. This is particularly useful, for example, |
| 1274 |
when people create what would be valid ‘HTML’, TeX or LaTeX files, |
| 1275 |
if only they were using provided sequences for applying diacritics |
| 1276 |
instead of using the diacriticised characters directly from the |
| 1277 |
underlying character set. |
| 1278 |
|
| 1279 |
While converting to ‘HTML’, ‘LaTeX’ or ‘BibTeX’ charset, this |
| 1280 |
option assumes that characters not in the said subset are properly |
| 1281 |
coded or protected already; Recode then transmits them literally. |
| 1282 |
While converting the other way, this option prevents translating |
| 1283 |
back coded or protected versions of characters not in the said |
| 1284 |
subset. *Note HTML::. *Note LaTeX::. *Note BibTeX::. |
| 1285 |
|
| 1286 |
‘-S[LANGUAGE]’ |
| 1287 |
‘--source[=LANGUAGE]’ |
| 1288 |
The bulk of the input file is expected to be written in ‘ASCII’, |
| 1289 |
except for parts, like comments and string constants, which are |
| 1290 |
written using another charset than ‘ASCII’. When LANGUAGE is ‘c’, |
| 1291 |
the recoding will proceed only with the contents of comments or |
| 1292 |
strings, while everything else will be copied without recoding. |
| 1293 |
When LANGUAGE is ‘po’, the recoding will proceed only within |
| 1294 |
translator comments (those having whitespace immediately following |
| 1295 |
the initial ‘#’) and with the contents of ‘msgstr’ strings. |
| 1296 |
|
| 1297 |
For the above things to work, the non-‘ASCII’ encoding of the |
| 1298 |
comment or string should be such that an ‘ASCII’ scan will |
| 1299 |
successfully find where the comment or string ends. |
| 1300 |
|
| 1301 |
Even if ‘ASCII’ is the usual charset for writing programs, some |
| 1302 |
compilers are able to directly read other charsets, like ‘UTF-8’, |
| 1303 |
say. There is currently no provision in Recode for reading mixed |
| 1304 |
charset sources which are not based on ‘ASCII’. It is probable |
| 1305 |
that the need for mixed recoding is not as pressing in such cases. |
| 1306 |
|
| 1307 |
For example, after one does: |
| 1308 |
|
| 1309 |
recode -Spo pc/..u8 < INPUT.po > OUTPUT.po |
| 1310 |
|
| 1311 |
file ‘OUTPUT.po’ holds a copy of ‘INPUT.po’ in which _only_ |
| 1312 |
translator comments and the contents of ‘msgstr’ strings have been |
| 1313 |
recoded from the ‘IBM-PC’ charset to pure ‘UTF-8’, without |
| 1314 |
attempting conversion of end-of-lines. Machine generated comments |
| 1315 |
and original ‘msgid’ strings are not to be touched by this |
| 1316 |
recoding. |
| 1317 |
|
| 1318 |
If LANGUAGE is not specified, ‘c’ is assumed. |
| 1319 |
|
| 1320 |
|
| 1321 |
File: recode.info, Node: Emacs, Next: Debugging, Prev: Mixed, Up: Invoking recode |
| 1322 |
|
| 1323 |
3.8 Using Recode within Emacs |
| 1324 |
============================= |
| 1325 |
|
| 1326 |
The fact the ‘recode’ program acts as a filter, when given no file |
| 1327 |
arguments, makes it quite easy to use from within GNU Emacs. For |
| 1328 |
example, recoding the whole buffer from the ‘IBM-PC’ charset to current |
| 1329 |
charset (for example, ‘UTF-8’ on Unix) is easily done with: |
| 1330 |
|
| 1331 |
C-x h C-u M-| recode ibmpc RET |
| 1332 |
|
| 1333 |
‘C-x h’ selects the whole buffer, and ‘C-u M-|’ filters and replaces the |
| 1334 |
current region through the given shell command. Here is another |
| 1335 |
example, binding the keys ‘C-c T’ to the recoding of the current region |
| 1336 |
from Easy French to ‘Latin-1’ (on Unix) and the key ‘C-u C-c T’ from |
| 1337 |
‘Latin-1’ (on Unix) to Easy French: |
| 1338 |
|
| 1339 |
(global-set-key "\C-cT" 'recode-texte) |
| 1340 |
|
| 1341 |
(defun recode-texte (flag) |
| 1342 |
(interactive "P") |
| 1343 |
(shell-command-on-region |
| 1344 |
(region-beginning) (region-end) |
| 1345 |
(concat "recode " (if flag "..txte" "txte")) t) |
| 1346 |
(exchange-point-and-mark)) |
| 1347 |
|
| 1348 |
|
| 1349 |
File: recode.info, Node: Debugging, Prev: Emacs, Up: Invoking recode |
| 1350 |
|
| 1351 |
3.9 Debugging considerations |
| 1352 |
============================ |
| 1353 |
|
| 1354 |
It is our experience that when Recode does not provide satisfying |
| 1355 |
results, either the ‘recode’ program was not called properly, correct |
| 1356 |
results raised some doubts nevertheless, or files to recode were |
| 1357 |
somewhat mangled. Genuine bugs are surely possible. |
| 1358 |
|
| 1359 |
Unless you already are a Recode expert, it might be a good idea to |
| 1360 |
quickly revisit the tutorial (*note Tutorial::) or the prior sections in |
| 1361 |
this chapter, to make sure that you properly formatted your recoding |
| 1362 |
request. In the case you intended to use Recode as a filter, make sure |
| 1363 |
that you did not forget to redirect your standard input (through using |
| 1364 |
the ‘<’ symbol in the shell, say). Some Recode false mysteries are also |
| 1365 |
easily explained, *Note Reversibility::. |
| 1366 |
|
| 1367 |
For the other cases, some investigation is needed. To illustrate how |
| 1368 |
to proceed, let's presume that you want to recode the ‘nicepage’ file, |
| 1369 |
coded ‘UTF-8’, into ‘HTML’. The problem is that the command ‘recode |
| 1370 |
u8..h nicepage’ yields: |
| 1371 |
|
| 1372 |
recode: Invalid input in step `UTF-8..ISO-10646-UCS-2' |
| 1373 |
|
| 1374 |
One good trick is to use ‘recode’ in filter mode instead of in file |
| 1375 |
replacement mode, *Note Synopsis::. Another good trick is to use the |
| 1376 |
‘-v’ option asking for a verbose description of the recoding steps. We |
| 1377 |
could rewrite our recoding call as ‘recode -v u8..h <nicepage’, to get |
| 1378 |
something like: |
| 1379 |
|
| 1380 |
Request: UTF-8..:iconv:..ISO-10646-UCS-2..HTML_4.0 |
| 1381 |
Shrunk to: UTF-8..ISO-10646-UCS-2..HTML_4.0 |
| 1382 |
[...SOME OUTPUT...] |
| 1383 |
recode: Invalid input in step `UTF-8..ISO-10646-UCS-2' |
| 1384 |
|
| 1385 |
This might help you to better understand what the diagnostic means. |
| 1386 |
The recoding request is achieved in two steps, the first recodes ‘UTF-8’ |
| 1387 |
into ‘UCS-2’, the second recodes ‘UCS-2’ into ‘HTML’. The problem |
| 1388 |
occurs within the first of these two steps, and since, the input of this |
| 1389 |
step is the input file given to Recode, this is this overall input file |
| 1390 |
which seems to be invalid. Also, when used in filter mode, Recode |
| 1391 |
processes as much input as possible before the error occurs and sends |
| 1392 |
the result of this processing to standard output. Since the standard |
| 1393 |
output has not been redirected to a file, it is merely displayed on the |
| 1394 |
user screen. By inspecting near the end of the resulting ‘HTML’ output, |
| 1395 |
that is, what was recoding a bit before the recoding was interrupted, |
| 1396 |
you may infer about where the error stands in the real ‘UTF-8’ input |
| 1397 |
file. |
| 1398 |
|
| 1399 |
If you have the proper tools to examine the intermediate recoding |
| 1400 |
data, you might also prefer to reduce the problem to a single step to |
| 1401 |
better study it. This is what I usually do. For example, the last |
| 1402 |
‘recode’ call above is more or less equivalent to: |
| 1403 |
|
| 1404 |
recode -v UTF-8..ISO_10646-UCS-2 <nicepage >temporary |
| 1405 |
recode -v ISO_10646-UCS-2..HTML_4.0 <temporary |
| 1406 |
rm temporary |
| 1407 |
|
| 1408 |
If you know that the problem is within the first step, you might |
| 1409 |
prefer to concentrate on using the first ‘recode’ line. If you know |
| 1410 |
that the problem is within the second step, you might execute the first |
| 1411 |
‘recode’ line once and for all, and then play with the second ‘recode’ |
| 1412 |
call, repeatedly using the ‘temporary’ file created once by the first |
| 1413 |
call. |
| 1414 |
|
| 1415 |
Note that the ‘-f’ switch may be used to force the production of |
| 1416 |
‘HTML’ output despite invalid input, it might be satisfying enough for |
| 1417 |
you, and easier than repairing the input file. That depends on how |
| 1418 |
strict you would like to be about the precision of the recoding process. |
| 1419 |
|
| 1420 |
If you later see that your HTML file begins with ‘@lt;html@gt;’ when |
| 1421 |
you expected ‘<html>’, then Recode might have done a bit more that you |
| 1422 |
wanted. In this case, your input file was half-‘UTF-8’, half-‘HTML’ |
| 1423 |
already, that is, a mixed file (*note Mixed::). There is a special ‘-d’ |
| 1424 |
switch for this case. So, your might be end up calling ‘recode -fd |
| 1425 |
nicepage’. Until you are quite sure that you accept overwriting your |
| 1426 |
input file whatever what, I recommend that you stick with filter mode. |
| 1427 |
|
| 1428 |
If, after such experiments, you seriously think that Recode does not |
| 1429 |
behave properly, there might be a genuine bug either in the program or |
| 1430 |
the library itself, in which case I invite you to to contribute a bug |
| 1431 |
report, *Note Contributing::. |
| 1432 |
|
| 1433 |
|
| 1434 |
File: recode.info, Node: Library, Next: Universal, Prev: Invoking recode, Up: Top |
| 1435 |
|
| 1436 |
4 A recoding library |
| 1437 |
******************** |
| 1438 |
|
| 1439 |
The program named ‘recode’ is just an application of its recoding |
| 1440 |
library. The recoding library is available separately for other C |
| 1441 |
programs. A good way to acquire some familiarity with the recoding |
| 1442 |
library is to get acquainted with the ‘recode’ program itself. |
| 1443 |
|
| 1444 |
To use the recoding library once it is installed, a C program needs |
| 1445 |
to have the following lines: |
| 1446 |
|
| 1447 |
#include <stdlib.h> |
| 1448 |
#include <stdbool.h> |
| 1449 |
#include <recode.h> |
| 1450 |
|
| 1451 |
const char *program_name; |
| 1452 |
|
| 1453 |
near its beginning, and the user should have ‘-lrecode’ on the linking |
| 1454 |
call, so modules from the recoding library are found. |
| 1455 |
|
| 1456 |
The library contains four identifiable sets of routines: the outer |
| 1457 |
level functions, the request level functions, the task level functions |
| 1458 |
and the charset level functions. There are discussed in separate |
| 1459 |
sections. For effectively using the recoding library in most |
| 1460 |
applications, it should be rarely needed to study anything beyond the |
| 1461 |
main initialisation function at outer level, and then, various functions |
| 1462 |
at request level. |
| 1463 |
|
| 1464 |
* Menu: |
| 1465 |
|
| 1466 |
* Outer level:: Outer level functions |
| 1467 |
* Request level:: Request level functions |
| 1468 |
* Task level:: Task level functions |
| 1469 |
* Charset level:: Charset level functions |
| 1470 |
* Errors:: Handling errors |
| 1471 |
|
| 1472 |
|
| 1473 |
File: recode.info, Node: Outer level, Next: Request level, Prev: Library, Up: Library |
| 1474 |
|
| 1475 |
4.1 Outer level functions |
| 1476 |
========================= |
| 1477 |
|
| 1478 |
The outer level functions mainly prepare the whole recoding library for |
| 1479 |
use, or do actions which are unrelated to specific recodings. Here is |
| 1480 |
an example of a program which does not really make anything useful. |
| 1481 |
|
| 1482 |
#include <stdbool.h> |
| 1483 |
#include <stdlib.h> |
| 1484 |
#include <recode.h> |
| 1485 |
|
| 1486 |
const char *program_name; |
| 1487 |
|
| 1488 |
int |
| 1489 |
main (int argc, char *const *argv) |
| 1490 |
{ |
| 1491 |
program_name = argv[0]; |
| 1492 |
RECODE_OUTER outer = recode_new_outer (RECODE_AUTO_ABORT_FLAG); |
| 1493 |
|
| 1494 |
recode_delete_outer (outer); |
| 1495 |
exit (EXIT_SUCCESS); |
| 1496 |
} |
| 1497 |
|
| 1498 |
The header file ‘recode.h’ declares an opaque ‘RECODE_OUTER’ |
| 1499 |
structure, which the programmer should use for allocating a variable in |
| 1500 |
his program (let's assume the programmer is a male, here, no prejudice |
| 1501 |
intended). This ‘outer’ variable is given as a first argument to all |
| 1502 |
outer level functions. |
| 1503 |
|
| 1504 |
The ‘RECODE_OUTER’ structure is really meant to be initialised only |
| 1505 |
once in the life of a program, and terminated with the program itself. |
| 1506 |
Program interfaces should pay attention to initialise it only once, |
| 1507 |
would it be only for speed considerations. A good deal of overhead goes |
| 1508 |
to outer level initialization, and if the outer level was initialized |
| 1509 |
afresh for each and every string translated, say, the Recode library |
| 1510 |
would appear immensely much slower that it was meant to be! |
| 1511 |
|
| 1512 |
Because outer level initialization is meant to be done only once, not |
| 1513 |
so much attention has been paid to avoid memory leaks at this level |
| 1514 |
within Recode. This is hardly a reason for not plugging such leaks at |
| 1515 |
any level: in the long run, they should all be chased and repaired. |
| 1516 |
|
| 1517 |
• Initialisation functions |
| 1518 |
|
| 1519 |
RECODE_OUTER recode_new_outer (FLAGS); |
| 1520 |
bool recode_delete_outer (OUTER); |
| 1521 |
|
| 1522 |
The recoding library absolutely needs to be initialised before |
| 1523 |
being used, and ‘recode_new_outer’ has to be called once, first. |
| 1524 |
Besides the OUTER it is meant to initialise, the function accepts |
| 1525 |
an integer value holding zero or more flags. If no flags, use ‘0’. |
| 1526 |
If more than one flag, they should be combined with the bitwise-or |
| 1527 |
(‘|’) operator. The possible flags are: |
| 1528 |
|
| 1529 |
‘RECODE_AUTO_ABORT_FLAG’ |
| 1530 |
|
| 1531 |
When this flag is set, the library later issues diagnostics |
| 1532 |
itself, and aborts the calling program on errors. This is |
| 1533 |
merely a convenience, because if this flag was not given, the |
| 1534 |
calling program should always take care of checking the return |
| 1535 |
value of all other calls to the recoding library functions, |
| 1536 |
and when any error is detected, issue a diagnostic and abort |
| 1537 |
processing itself. |
| 1538 |
|
| 1539 |
‘RECODE_NO_ICONV_FLAG’ |
| 1540 |
|
| 1541 |
When this flag is set, the library does not initialize or use |
| 1542 |
the external ‘iconv’ library. This means that the charsets |
| 1543 |
and aliases provided by the ‘iconv’ external library and not |
| 1544 |
by Recode itself are not available. |
| 1545 |
|
| 1546 |
‘RECODE_STRICT_MAPPING_FLAG’ |
| 1547 |
|
| 1548 |
When this flag is set (corresponding to the ‘--strict’ |
| 1549 |
command-line option), untranslatable characters are discarded, |
| 1550 |
but an error is returned on completion unless |
| 1551 |
‘RECODE_FORCE_FLAG’ is also set. |
| 1552 |
|
| 1553 |
‘RECODE_FORCE_FLAG’ |
| 1554 |
|
| 1555 |
When this flag is set (corresponding to the ‘--force’ |
| 1556 |
command-line option), errors caused by untranslatable |
| 1557 |
characters are ignored. |
| 1558 |
|
| 1559 |
In previous incarnations of the Recode library, FLAGS was a Boolean |
| 1560 |
instead of a collection of flags, meant to set |
| 1561 |
‘RECODE_AUTO_ABORT_FLAG’. This still works, but is deprecated. |
| 1562 |
|
| 1563 |
Regardless of the setting of ‘RECODE_AUTO_ABORT’, all recoding |
| 1564 |
library functions return a success status. Most functions are |
| 1565 |
geared for returning ‘false’ for an error, and ‘true’ if everything |
| 1566 |
went fine. Functions returning structures or strings return ‘NULL’ |
| 1567 |
instead of the result, when the result cannot be produced. If |
| 1568 |
RECODE_AUTO_ABORT is selected, functions either return ‘true’, or |
| 1569 |
do not return at all. |
| 1570 |
|
| 1571 |
As in the example above, ‘recode_new_outer’ is called only once in |
| 1572 |
most cases. Calling ‘recode_new_outer’ implies some overhead, so |
| 1573 |
calling it more than once should preferably be avoided. |
| 1574 |
|
| 1575 |
The termination function ‘recode_delete_outer’ reclaims the memory |
| 1576 |
allocated by ‘recode_new_outer’ for a given OUTER variable. |
| 1577 |
Calling ‘recode_delete_outer’ prior to program termination is more |
| 1578 |
aesthetic then useful, as all memory resources are automatically |
| 1579 |
reclaimed when the program ends. You may spare this terminating |
| 1580 |
call if you prefer. |
| 1581 |
|
| 1582 |
• The ‘program_name’ declaration |
| 1583 |
|
| 1584 |
As we just explained, the user may set the Recode library so that, |
| 1585 |
in case of problems error, it issues the diagnostic itself and |
| 1586 |
aborts the whole processing. This capability may be quite |
| 1587 |
convenient. When this feature is used, the aborting routine |
| 1588 |
includes the name of the running program in the diagnostic. On the |
| 1589 |
other hand, when this feature is not used, the library merely |
| 1590 |
return error codes, giving the library user fuller control over all |
| 1591 |
this. This behaviour is more like what usual libraries do: they |
| 1592 |
return codes and never abort. However, I would rather not force |
| 1593 |
library users to necessarily check all return codes themselves, by |
| 1594 |
leaving no other choice. In most simple applications, letting the |
| 1595 |
library diagnose and abort is much easier, and quite welcome. This |
| 1596 |
is precisely because both possibilities exist that the |
| 1597 |
‘program_name’ variable is needed: it may be used by the library |
| 1598 |
_when_ the user sets it to diagnose itself. |
| 1599 |
|
| 1600 |
|
| 1601 |
File: recode.info, Node: Request level, Next: Task level, Prev: Outer level, Up: Library |
| 1602 |
|
| 1603 |
4.2 Request level functions |
| 1604 |
=========================== |
| 1605 |
|
| 1606 |
The request level functions are meant to cover most recoding needs |
| 1607 |
programmers may have; they should provide all usual functionality. |
| 1608 |
Their API is almost stable by now. |
| 1609 |
|
| 1610 |
To get started with request level functions, here is a full example |
| 1611 |
of a program which sole job is to filter ‘ibmpc’ code on its standard |
| 1612 |
input into ‘latin1’ code on its standard output. |
| 1613 |
|
| 1614 |
#include <stdbool.h> |
| 1615 |
#include <stdio.h> |
| 1616 |
#include <stdlib.h> |
| 1617 |
#include <recode.h> |
| 1618 |
|
| 1619 |
const char *program_name; |
| 1620 |
|
| 1621 |
int |
| 1622 |
main (int argc, char *const *argv) |
| 1623 |
{ |
| 1624 |
program_name = argv[0]; |
| 1625 |
RECODE_OUTER outer = recode_new_outer (RECODE_AUTO_ABORT_FLAG); |
| 1626 |
RECODE_REQUEST request = recode_new_request (outer); |
| 1627 |
bool success; |
| 1628 |
|
| 1629 |
recode_scan_request (request, "ibmpc..latin1"); |
| 1630 |
|
| 1631 |
success = recode_file_to_file (request, stdin, stdout); |
| 1632 |
|
| 1633 |
recode_delete_request (request); |
| 1634 |
recode_delete_outer (outer); |
| 1635 |
|
| 1636 |
exit (success ? EXIT_SUCCESS : EXIT_FAILURE); |
| 1637 |
} |
| 1638 |
|
| 1639 |
The header file ‘recode.h’ declares a ‘RECODE_REQUEST’ structure, |
| 1640 |
which the programmer should use for allocating a variable in his |
| 1641 |
program. This REQUEST variable is given as a first argument to all |
| 1642 |
request level functions, and in most cases, may be considered as opaque. |
| 1643 |
|
| 1644 |
Suppose an application is doing a lot of recoding using only a few |
| 1645 |
different requests. For speed considerations, the ‘RECODE_REQUEST’ |
| 1646 |
structure should ideally be cached for each kind of request, so the |
| 1647 |
request level initialisation is not redone for each and every string |
| 1648 |
translated. The speedup should be more apparent when Recode is able to |
| 1649 |
optimize the work by building on the fly, within the structure, new |
| 1650 |
specialized recoding steps and their associated data tables. |
| 1651 |
|
| 1652 |
• Initialisation functions |
| 1653 |
|
| 1654 |
RECODE_REQUEST recode_new_request (OUTER); |
| 1655 |
bool recode_delete_request (REQUEST); |
| 1656 |
|
| 1657 |
No REQUEST variable may not be used in other request level |
| 1658 |
functions of the recoding library before having been initialised by |
| 1659 |
‘recode_new_request’. There may be many such REQUEST variables, in |
| 1660 |
which case, they are independent of one another and they all need |
| 1661 |
to be initialised separately. To avoid memory leaks, a REQUEST |
| 1662 |
variable should not be initialised a second time without calling |
| 1663 |
‘recode_delete_request’ to "un-initialise" it. |
| 1664 |
|
| 1665 |
Like for ‘recode_delete_outer’, calling ‘recode_delete_request’ |
| 1666 |
prior to program termination, in the example above, may be left |
| 1667 |
out. |
| 1668 |
|
| 1669 |
• Fields of ‘struct recode_request’ |
| 1670 |
|
| 1671 |
Here are the fields of a ‘struct recode_request’ which may be |
| 1672 |
meaningfully changed, once a REQUEST has been initialised by |
| 1673 |
‘recode_new_request’, but before it gets used. It is not very |
| 1674 |
frequent, in practice, that these fields need to be changed. To |
| 1675 |
access the fields, you need to include ‘recodext.h’ _instead_ of |
| 1676 |
‘recode.h’, in which case there also is a greater chance that you |
| 1677 |
need to recompile your programs if a new version of the recoding |
| 1678 |
library gets installed. |
| 1679 |
|
| 1680 |
‘verbose_flag’ |
| 1681 |
This field is initially ‘false’. When set to ‘true’, the |
| 1682 |
library will echo to stderr the sequence of elementary |
| 1683 |
recoding steps needed to achieve the requested recoding. |
| 1684 |
|
| 1685 |
‘diaeresis_char’ |
| 1686 |
This field is initially the ASCII value of a double quote ‘"’, |
| 1687 |
but it may also be the ASCII value of a colon ‘:’. In ‘texte’ |
| 1688 |
charset, some countries use double quotes to mark diaeresis, |
| 1689 |
while other countries prefer colons. This field contains the |
| 1690 |
diaeresis character for the ‘texte’ charset. |
| 1691 |
|
| 1692 |
‘make_header_flag’ |
| 1693 |
This field is initially ‘false’. When set to ‘true’, it |
| 1694 |
indicates that the program is merely trying to produce a |
| 1695 |
recoding table in source form rather than completing any |
| 1696 |
actual recoding. In such a case, the optimisation of step |
| 1697 |
sequence can be attempted much more aggressively. If the step |
| 1698 |
sequence cannot be reduced to a single step, table production |
| 1699 |
will fail. |
| 1700 |
|
| 1701 |
‘diacritics_only’ |
| 1702 |
This field is initially ‘false’. For ‘HTML’, ‘LaTeX’ and |
| 1703 |
‘BibTeX’ charset, it is often convenient to recode the |
| 1704 |
diacriticized characters only, while just not recoding other |
| 1705 |
HTML code using ampersands or angular brackets, or LaTeX code |
| 1706 |
using backslashes. Set the field to ‘true’ for getting this |
| 1707 |
behaviour. In the other charset, one can edit text as well as |
| 1708 |
HTML or LaTeX directives. |
| 1709 |
|
| 1710 |
‘ascii_graphics’ |
| 1711 |
This field is initially ‘false’, and relate to characters 176 |
| 1712 |
to 223 in the ‘ibmpc’ charset, which are use to draw boxes. |
| 1713 |
When set to ‘true’, while getting out of ‘ibmpc’, ASCII |
| 1714 |
characters are selected so to graphically approximate these |
| 1715 |
boxes. |
| 1716 |
|
| 1717 |
• Study of request strings |
| 1718 |
|
| 1719 |
bool recode_scan_request (REQUEST, "STRING"); |
| 1720 |
|
| 1721 |
The main role of a REQUEST variable is to describe a set of |
| 1722 |
recoding transformations. Function ‘recode_scan_request’ studies |
| 1723 |
the given STRING, and stores an internal representation of it into |
| 1724 |
REQUEST. Note that STRING may be a full-fledged Recode request, |
| 1725 |
possibly including surfaces specifications, intermediary charsets, |
| 1726 |
sequences, aliases or abbreviations (*note Requests::). |
| 1727 |
|
| 1728 |
The internal representation automatically receives some |
| 1729 |
pre-conditioning and optimisation, so the REQUEST may then later be |
| 1730 |
used many times to achieve many actual recodings. It would not be |
| 1731 |
efficient calling ‘recode_scan_request’ many times with the same |
| 1732 |
STRING, it is better having many REQUEST variables instead. |
| 1733 |
|
| 1734 |
• Actual recoding jobs |
| 1735 |
|
| 1736 |
Once the REQUEST variable holds the description of a recoding |
| 1737 |
transformation, a few functions use it for achieving an actual |
| 1738 |
recoding. Either input or output of a recoding may be string, an |
| 1739 |
in-memory buffer, or a file. |
| 1740 |
|
| 1741 |
Functions with names like ‘recode_INPUT-TYPE_to_OUTPUT-TYPE’ |
| 1742 |
request an actual recoding, and are described below. It is easy to |
| 1743 |
remember which arguments each function accepts, once grasped some |
| 1744 |
simple principles for each possible TYPE. However, one of the |
| 1745 |
recoding function escapes these principles and is discussed |
| 1746 |
separately, first. |
| 1747 |
|
| 1748 |
recode_string (REQUEST, STRING); |
| 1749 |
|
| 1750 |
The function ‘recode_string’ recodes STRING according to REQUEST, |
| 1751 |
and directly returns the resulting recoded string freshly |
| 1752 |
allocated, or ‘NULL’ if the recoding could not succeed for some |
| 1753 |
reason. When this function is used, it is the responsibility of |
| 1754 |
the programmer to ensure that the memory used by the returned |
| 1755 |
string is later reclaimed. |
| 1756 |
|
| 1757 |
char *recode_string_to_buffer (REQUEST, |
| 1758 |
INPUT_STRING, |
| 1759 |
&OUTPUT_BUFFER, &OUTPUT_LENGTH, &OUTPUT_ALLOCATED); |
| 1760 |
bool recode_string_to_file (REQUEST, |
| 1761 |
INPUT_FILE, |
| 1762 |
OUTPUT_FILE); |
| 1763 |
bool recode_buffer_to_buffer (REQUEST, |
| 1764 |
INPUT_BUFFER, INPUT_LENGTH, |
| 1765 |
&OUTPUT_BUFFER, &OUTPUT_LENGTH, &OUTPUT_ALLOCATED); |
| 1766 |
bool recode_buffer_to_file (REQUEST, |
| 1767 |
INPUT_BUFFER, INPUT_LENGTH, |
| 1768 |
OUTPUT_FILE); |
| 1769 |
bool recode_file_to_buffer (REQUEST, |
| 1770 |
INPUT_FILE, |
| 1771 |
&OUTPUT_BUFFER, &OUTPUT_LENGTH, &OUTPUT_ALLOCATED); |
| 1772 |
bool recode_file_to_file (REQUEST, |
| 1773 |
INPUT_FILE, |
| 1774 |
OUTPUT_FILE); |
| 1775 |
|
| 1776 |
All these functions return a ‘bool’ result, ‘false’ meaning that |
| 1777 |
the recoding was not successful, often because of reversibility |
| 1778 |
issues. The name of the function well indicates on which types it |
| 1779 |
reads and which type it produces. Let's discuss these three types |
| 1780 |
in turn. |
| 1781 |
|
| 1782 |
string |
| 1783 |
|
| 1784 |
A string is merely an in-memory buffer which is terminated by |
| 1785 |
a ‘NUL’ character (using as many bytes as needed), instead of |
| 1786 |
being described by a byte length. For input, a pointer to the |
| 1787 |
buffer is given through one argument. |
| 1788 |
|
| 1789 |
It is notable that there is no ‘to_string’ functions. Only |
| 1790 |
one function recodes into a string, and it is ‘recode_string’, |
| 1791 |
which has already been discussed separately, above. |
| 1792 |
|
| 1793 |
buffer |
| 1794 |
|
| 1795 |
A buffer is a sequence of bytes held in computer memory. For |
| 1796 |
input, two arguments provide a pointer to the start of the |
| 1797 |
buffer and its byte size. Note that for charsets using many |
| 1798 |
bytes per character, the size is given in bytes, not in |
| 1799 |
characters. |
| 1800 |
|
| 1801 |
For output, three arguments provide the address of three |
| 1802 |
variables, which will receive the buffer pointer, the used |
| 1803 |
buffer size in bytes, and the allocated buffer size in bytes. |
| 1804 |
If at the time of the call, the buffer pointer is ‘NULL’, then |
| 1805 |
the allocated buffer size should also be zero, and the buffer |
| 1806 |
will be allocated afresh by the recoding functions. However, |
| 1807 |
if the buffer pointer is not ‘NULL’, it should be already |
| 1808 |
allocated, the allocated buffer size then gives its size. If |
| 1809 |
the allocated size gets exceeded while the recoding goes, the |
| 1810 |
buffer will be automatically reallocated bigger, probably |
| 1811 |
elsewhere, and the allocated buffer size will be adjusted |
| 1812 |
accordingly. |
| 1813 |
|
| 1814 |
The second variable, giving the in-memory buffer size, will |
| 1815 |
receive the exact byte size which was needed for the recoding. |
| 1816 |
A ‘NUL’ character is guaranteed at the end of the produced |
| 1817 |
buffer, but is not counted in the byte size of the recoding. |
| 1818 |
Beyond that ‘NUL’, there might be some extra space after the |
| 1819 |
recoded data, extending to the allocated buffer size. |
| 1820 |
|
| 1821 |
file |
| 1822 |
|
| 1823 |
A file is a sequence of bytes held outside computer memory, |
| 1824 |
but buffered through it. For input, one argument provides a |
| 1825 |
pointer to a file already opened for read. The file is then |
| 1826 |
read and recoded from its current position until the end of |
| 1827 |
the file, effectively swallowing it in memory if the |
| 1828 |
destination of the recoding is a buffer. For reading a file |
| 1829 |
filtered through the recoding library, but only a little bit |
| 1830 |
at a time, one should rather use ‘recode_filter_open’ and |
| 1831 |
‘recode_filter_close’ (these two functions are not yet |
| 1832 |
available). |
| 1833 |
|
| 1834 |
For output, one argument provides a pointer to a file already |
| 1835 |
opened for write. The result of the recoding is written to |
| 1836 |
that file starting at its current position. |
| 1837 |
|
| 1838 |
The following special function is still subject to change: |
| 1839 |
|
| 1840 |
void recode_format_table (REQUEST, LANGUAGE, "NAME"); |
| 1841 |
|
| 1842 |
and is not documented anymore for now. |
| 1843 |
|
| 1844 |
|
| 1845 |
File: recode.info, Node: Task level, Next: Charset level, Prev: Request level, Up: Library |
| 1846 |
|
| 1847 |
4.3 Task level functions |
| 1848 |
======================== |
| 1849 |
|
| 1850 |
The task level functions are used internally by the request level |
| 1851 |
functions, they allow more explicit control over files and memory |
| 1852 |
buffers holding input and output to recoding processes. The interface |
| 1853 |
specification of task level functions is still subject to change a bit. |
| 1854 |
|
| 1855 |
To get started with task level functions, here is a full example of a |
| 1856 |
program which sole job is to filter ‘ibmpc’ code on its standard input |
| 1857 |
into ‘latin1’ code on its standard output. That is, this program has |
| 1858 |
the same goal as the one from the previous section, but does its things |
| 1859 |
a bit differently. |
| 1860 |
|
| 1861 |
#include <stdbool.h> |
| 1862 |
#include <stdlib.h> |
| 1863 |
#include <recodext.h> |
| 1864 |
|
| 1865 |
const char *program_name; |
| 1866 |
|
| 1867 |
int |
| 1868 |
main (int argc, char *const *argv) |
| 1869 |
{ |
| 1870 |
program_name = argv[0]; |
| 1871 |
RECODE_OUTER outer = recode_new_outer (0); |
| 1872 |
RECODE_REQUEST request = recode_new_request (outer); |
| 1873 |
RECODE_TASK task; |
| 1874 |
bool success; |
| 1875 |
|
| 1876 |
recode_scan_request (request, "ibmpc..latin1"); |
| 1877 |
|
| 1878 |
task = recode_new_task (request); |
| 1879 |
task->input.name = ""; |
| 1880 |
task->output.name = ""; |
| 1881 |
success = recode_perform_task (task); |
| 1882 |
|
| 1883 |
recode_delete_task (task); |
| 1884 |
recode_delete_request (request); |
| 1885 |
recode_delete_outer (outer); |
| 1886 |
|
| 1887 |
exit (success ? EXIT_SUCCESS : EXIT_FAILURE); |
| 1888 |
} |
| 1889 |
|
| 1890 |
Note that in the example above, ‘recodext.h’ header is used instead |
| 1891 |
of ‘recode.h’. By doing so, the various structures are not opaque |
| 1892 |
anymore, and their fields may be accessed by name. |
| 1893 |
|
| 1894 |
The header file ‘recode.h’ declares a ‘RECODE_TASK’ structure, which |
| 1895 |
the programmer should use for allocating a variable in his program. |
| 1896 |
This ‘task’ variable is given as a first argument to all task level |
| 1897 |
functions. The programmer ought to change and possibly consult a few |
| 1898 |
fields in this structure, using special functions. |
| 1899 |
|
| 1900 |
• Initialisation functions |
| 1901 |
|
| 1902 |
RECODE_TASK recode_new_task (REQUEST); |
| 1903 |
bool recode_delete_task (TASK); |
| 1904 |
|
| 1905 |
No TASK variable may be used in other task level functions of the |
| 1906 |
recoding library without having first been initialised with |
| 1907 |
‘recode_new_task’. There may be many such TASK variables, in which |
| 1908 |
case, they are independent of one another and they all need to be |
| 1909 |
initialised separately. To avoid memory leaks, a TASK variable |
| 1910 |
should not be initialised a second time without calling |
| 1911 |
‘recode_delete_task’ to "un-initialise" it. This function also |
| 1912 |
accepts a REQUEST argument and associates the request to the task. |
| 1913 |
In fact, a task is essentially a set of recoding transformations |
| 1914 |
with the specification for its current input and its current |
| 1915 |
output. |
| 1916 |
|
| 1917 |
The REQUEST variable may be scanned before or after the call to |
| 1918 |
‘recode_new_task’, it does not matter so far. Immediately after |
| 1919 |
initialisation, before further changes, the TASK variable |
| 1920 |
associates REQUEST empty in-memory buffers for both input and |
| 1921 |
output. The output buffer will later get allocated automatically |
| 1922 |
on the fly, as needed, by various task processors. |
| 1923 |
|
| 1924 |
Even if a call to ‘recode_delete_task’ is not strictly mandatory |
| 1925 |
before ending the program, it is cleaner to always include it. |
| 1926 |
Moreover, in some future version of the recoding library, it might |
| 1927 |
become required. |
| 1928 |
|
| 1929 |
• Fields of ‘struct task_request’ |
| 1930 |
|
| 1931 |
Here are the fields of a ‘struct task_request’ which may be |
| 1932 |
meaningfully changed, once a TASK has been initialised by |
| 1933 |
‘recode_new_task’. In fact, fields are expected to change. Once |
| 1934 |
again, to access the fields, you need to include ‘recodext.h’ |
| 1935 |
_instead_ of ‘recode.h’, in which case there also is a greater |
| 1936 |
chance that you need to recompile your programs if a new version of |
| 1937 |
the recoding library gets installed. |
| 1938 |
|
| 1939 |
‘request’ |
| 1940 |
|
| 1941 |
The field ‘request’ points to the current recoding request, |
| 1942 |
but may be changed as needed between recoding calls, for |
| 1943 |
example when there is a need to achieve the construction of a |
| 1944 |
resulting text made up of many pieces, each being recoded |
| 1945 |
differently. |
| 1946 |
|
| 1947 |
‘input.name’ |
| 1948 |
‘input.file’ |
| 1949 |
|
| 1950 |
If ‘input.name’ is not ‘NULL’ at start of a recoding, this is |
| 1951 |
a request that a file by that name be first opened for reading |
| 1952 |
and later automatically closed once the whole file has been |
| 1953 |
read. If the file name is not ‘NULL’ but an empty string, it |
| 1954 |
means that standard input is to be used. The opened file |
| 1955 |
pointer is then held into ‘input.file’. |
| 1956 |
|
| 1957 |
If ‘input.name’ is ‘NULL’ and ‘input.file’ is not, than |
| 1958 |
‘input.file’ should point to a file already opened for read, |
| 1959 |
which is meant to be recoded. |
| 1960 |
|
| 1961 |
‘input.buffer’ |
| 1962 |
‘input.cursor’ |
| 1963 |
‘input.limit’ |
| 1964 |
|
| 1965 |
When both ‘input.name’ and ‘input.file’ are ‘NULL’, three |
| 1966 |
pointers describe an in-memory buffer containing the text to |
| 1967 |
be recoded. The buffer extends from ‘input.buffer’ to |
| 1968 |
‘input.limit’, yet the text to be recoded only extends from |
| 1969 |
‘input.cursor’ to ‘input.limit’. In most situations, |
| 1970 |
‘input.cursor’ starts with the value that ‘input.buffer’ has. |
| 1971 |
(Its value will internally advance as the recoding goes, until |
| 1972 |
it reaches the value of ‘input.limit’.) |
| 1973 |
|
| 1974 |
‘output.name’ |
| 1975 |
‘output.file’ |
| 1976 |
|
| 1977 |
If ‘output.name’ is not ‘NULL’ at start of a recoding, this is |
| 1978 |
a request that a file by that name be opened for write and |
| 1979 |
later automatically closed after the recoding is done. If the |
| 1980 |
file name is not ‘NULL’ but an empty string, it means that |
| 1981 |
standard output is to be used. The opened file pointer is |
| 1982 |
then held into ‘output.file’. If several passes with |
| 1983 |
intermediate files are needed to produce the recoding, the |
| 1984 |
‘output.name’ file is opened only for the final pass. |
| 1985 |
|
| 1986 |
If ‘output.name’ is ‘NULL’ and ‘output.file’ is not, then |
| 1987 |
‘output.file’ should point to a file already opened for write, |
| 1988 |
which will receive the result of the recoding. |
| 1989 |
|
| 1990 |
‘output.buffer’ |
| 1991 |
‘output.cursor’ |
| 1992 |
‘output.limit’ |
| 1993 |
|
| 1994 |
When both ‘output.name’ and ‘output.file’ are ‘NULL’, three |
| 1995 |
pointers describe an in-memory buffer meant to receive the |
| 1996 |
text, once it is recoded. The buffer is already allocated |
| 1997 |
from ‘output.buffer’ to ‘output.limit’. In most situations, |
| 1998 |
‘output.cursor’ starts with the value that ‘output.buffer’ |
| 1999 |
has. Once the recoding is done, ‘output.cursor’ will point at |
| 2000 |
the next free byte in the buffer, just after the recoded text, |
| 2001 |
so another recoding could be called without changing any of |
| 2002 |
these three pointers, for appending new information to it. |
| 2003 |
The number of recoded bytes in the buffer is the difference |
| 2004 |
between ‘output.cursor’ and ‘output.buffer’. |
| 2005 |
|
| 2006 |
Each time ‘output.cursor’ reaches ‘output.limit’, the buffer |
| 2007 |
is reallocated bigger, possibly at a different location in |
| 2008 |
memory, always held up-to-date in ‘output.buffer’. It is |
| 2009 |
still possible to call a task level function with no output |
| 2010 |
buffer at all to start with, in which case all three fields |
| 2011 |
should have ‘NULL’ as a value. This is the situation |
| 2012 |
immediately after a call to ‘recode_new_task’. |
| 2013 |
|
| 2014 |
‘byte_order_mark’ |
| 2015 |
This field, which is preset to ‘true’, indicates that a byte |
| 2016 |
order mark is to be expected at the beginning of any canonical |
| 2017 |
‘UCS-2’ or ‘UTF-16’ text, and that such a byte order mark |
| 2018 |
should be also produced for these charsets. |
| 2019 |
|
| 2020 |
‘fail_level’ |
| 2021 |
This field, which is of type ‘enum recode_error’ (*note |
| 2022 |
Errors::), sets the error level at which task level functions |
| 2023 |
should report a failure. If an error being detected is equal |
| 2024 |
or greater than ‘fail_level’, the function will eventually |
| 2025 |
return ‘false’ instead of ‘true’. The preset value for this |
| 2026 |
field is ‘RECODE_NOT_CANONICAL’, that means that if not reset |
| 2027 |
to another value, the library will report failure on _any_ |
| 2028 |
error. |
| 2029 |
|
| 2030 |
‘abort_level’ |
| 2031 |
This field, which is of type ‘enum recode_error’ (*note |
| 2032 |
Errors::), sets the error level at which task level functions |
| 2033 |
should immediately interrupt their processing. If an error |
| 2034 |
being detected is equal or greater than ‘abort_level’, the |
| 2035 |
function returns immediately, but the returned value (‘true’ |
| 2036 |
or ‘false’) is still is decided from the setting of |
| 2037 |
‘fail_level’, not ‘abort_level’. The preset value for this |
| 2038 |
field is ‘RECODE_MAXIMUM_ERROR’, that means that is not reset |
| 2039 |
to another value, the library will never interrupt a recoding |
| 2040 |
task. |
| 2041 |
|
| 2042 |
‘error_so_far’ |
| 2043 |
This field, which is of type ‘enum recode_error’ (*note |
| 2044 |
Errors::), maintains the maximum error level met so far while |
| 2045 |
the recoding task was proceeding. The preset value is |
| 2046 |
‘RECODE_NO_ERROR’. |
| 2047 |
|
| 2048 |
• Task execution |
| 2049 |
|
| 2050 |
recode_perform_task (TASK); |
| 2051 |
recode_filter_open (TASK, FILE); |
| 2052 |
recode_filter_close (TASK); |
| 2053 |
|
| 2054 |
The function ‘recode_perform_task’ reads as much input as possible, |
| 2055 |
and recode all of it on prescribed output, given a properly |
| 2056 |
initialised TASK. |
| 2057 |
|
| 2058 |
Functions ‘recode_filter_open’ and ‘recode_filter_close’ are only |
| 2059 |
planned for now. They are meant to read input in piecemeal ways. |
| 2060 |
Even if functionality already exists informally in the library, it |
| 2061 |
has not been made available yet through such interface functions. |
| 2062 |
|
| 2063 |
|
| 2064 |
File: recode.info, Node: Charset level, Next: Errors, Prev: Task level, Up: Library |
| 2065 |
|
| 2066 |
4.4 Charset level functions |
| 2067 |
=========================== |
| 2068 |
|
| 2069 |
Many functions are internal to the recoding library. Some of them have |
| 2070 |
been made external and available, for the ‘recode’ program had to retain |
| 2071 |
all its previous functionality while being transformed into a mere |
| 2072 |
application of the recoding library. These functions are not really |
| 2073 |
documented here for the time being, as we hope that many of them will |
| 2074 |
vanish over time. When this set of routines will stabilise, it would be |
| 2075 |
convenient to document them as an API for handling charset names and |
| 2076 |
contents. |
| 2077 |
|
| 2078 |
RECODE_CHARSET find_charset (NAME, CLEANING-TYPE); |
| 2079 |
bool list_all_charsets (CHARSET); |
| 2080 |
bool list_concise_charset (CHARSET, LIST-FORMAT); |
| 2081 |
bool list_full_charset (CHARSET); |
| 2082 |
|
| 2083 |
|
| 2084 |
File: recode.info, Node: Errors, Prev: Charset level, Up: Library |
| 2085 |
|
| 2086 |
4.5 Handling errors |
| 2087 |
=================== |
| 2088 |
|
| 2089 |
The ‘recode’ program, while using the Recode library, needs to control |
| 2090 |
whether recoding problems are reported or not, and then reflect these in |
| 2091 |
the exit status. The program should also instruct the library whether |
| 2092 |
the recoding should be abruptly interrupted when an error is met (so |
| 2093 |
sparing processing when it is known in advance that a wrong result would |
| 2094 |
be discarded anyway), or if it should proceed nevertheless. Here is how |
| 2095 |
the library groups errors into levels, listed here in order of |
| 2096 |
increasing severity. |
| 2097 |
|
| 2098 |
‘RECODE_NO_ERROR’ |
| 2099 |
|
| 2100 |
No error was met on previous library calls. |
| 2101 |
|
| 2102 |
‘RECODE_NOT_CANONICAL’ |
| 2103 |
|
| 2104 |
The input text was using one of the many alternative codings for |
| 2105 |
some phenomenon, but not the one Recode would have canonically |
| 2106 |
generated. So, if the reverse recoding is later attempted, it |
| 2107 |
would produce a text having the same _meaning_ as the original |
| 2108 |
text, yet not being byte identical. |
| 2109 |
|
| 2110 |
For example, a ‘Base64’ block in which end-of-lines appear |
| 2111 |
elsewhere that at every 76 characters is not canonical. An |
| 2112 |
e-circumflex in TeX which is coded as ‘\^{e}’ instead of ‘\^e’ is |
| 2113 |
not canonical. |
| 2114 |
|
| 2115 |
‘RECODE_AMBIGUOUS_OUTPUT’ |
| 2116 |
|
| 2117 |
It has been discovered that if the reverse recoding was attempted |
| 2118 |
on the text output by this recoding, we would not obtain the |
| 2119 |
original text, only because an ambiguity was generated by accident |
| 2120 |
in the output text. This ambiguity would then cause the wrong |
| 2121 |
interpretation to be taken. |
| 2122 |
|
| 2123 |
Here are a few examples. If the ‘Latin-1’ sequence ‘e^’ is |
| 2124 |
converted to Easy French and back, the result will be interpreted |
| 2125 |
as e-circumflex and so, will not reflect the intent of the original |
| 2126 |
two characters. Recoding an ‘IBM-PC’ text to ‘Latin-1’ and back, |
| 2127 |
where the input text contained an isolated ‘LF’, will have a |
| 2128 |
spurious ‘CR’ inserted before the ‘LF’. |
| 2129 |
|
| 2130 |
Currently, there are many cases in the library where the production |
| 2131 |
of ambiguous output is not properly detected, as it is sometimes a |
| 2132 |
difficult problem to accomplish this detection, or to do it |
| 2133 |
speedily. |
| 2134 |
|
| 2135 |
‘RECODE_UNTRANSLATABLE’ |
| 2136 |
|
| 2137 |
One or more input character could not be recoded, because there is |
| 2138 |
just no representation for this character in the output charset. |
| 2139 |
|
| 2140 |
Here are a few examples. Non-strict mode often allows Recode to |
| 2141 |
compute on-the-fly mappings for unrepresentable characters, but |
| 2142 |
strict mode prohibits such attribution of reversible translations: |
| 2143 |
so strict mode might often trigger such an error. Most ‘UCS-2’ |
| 2144 |
codes used to represent Asian characters cannot be expressed in |
| 2145 |
various Latin charsets. |
| 2146 |
|
| 2147 |
Since iconv does not distinguish untranslatable from invalid input, |
| 2148 |
Recode has to use a workaround to detect when input is |
| 2149 |
untranslatable. Unfortunately, it cannot currently tell how much |
| 2150 |
input is untranslatable, so it cannot reliably skip such input: |
| 2151 |
typically the input is then diagnosed as invalid. Two possible |
| 2152 |
workarounds are to set the ‘abort_level’ to |
| 2153 |
‘RECODE_UNTRANSLATABLE’, or not to use iconv. |
| 2154 |
|
| 2155 |
‘RECODE_INVALID_INPUT’ |
| 2156 |
|
| 2157 |
The input text does not comply with the coding it is declared to |
| 2158 |
hold. So, there is no way by which a reverse recoding would |
| 2159 |
reproduce this text, because Recode should never produce invalid |
| 2160 |
output. |
| 2161 |
|
| 2162 |
Here are a few examples. In strict mode, ‘ASCII’ text is not |
| 2163 |
allowed to contain characters with the eight bit set. ‘UTF-8’ |
| 2164 |
encodings ought to be minimal(1). |
| 2165 |
|
| 2166 |
‘RECODE_SYSTEM_ERROR’ |
| 2167 |
|
| 2168 |
The underlying system reported an error while the recoding was |
| 2169 |
going on, likely an input/output error. (This error symbol is |
| 2170 |
currently unused in the library.) |
| 2171 |
|
| 2172 |
‘RECODE_USER_ERROR’ |
| 2173 |
|
| 2174 |
The programmer or user requested something the recoding library is |
| 2175 |
unable to provide, or used the API wrongly. (This error symbol is |
| 2176 |
currently unused in the library.) |
| 2177 |
|
| 2178 |
‘RECODE_INTERNAL_ERROR’ |
| 2179 |
|
| 2180 |
Something really wrong, which should normally never happen, was |
| 2181 |
detected within the recoding library. This might be due to genuine |
| 2182 |
bugs in the library, or maybe due to un-initialised or overwritten |
| 2183 |
arguments to the API. (This error symbol is currently unused in the |
| 2184 |
library.) |
| 2185 |
|
| 2186 |
‘RECODE_MAXIMUM_ERROR’ |
| 2187 |
|
| 2188 |
This error code should never be returned, it is only internally |
| 2189 |
used as a sentinel for the list of all possible error codes. |
| 2190 |
|
| 2191 |
One should be able to set the error level threshold for returning |
| 2192 |
failure at end of recoding, and also the threshold for immediate |
| 2193 |
interruption. If many errors occur while the recoding proceed, which |
| 2194 |
are not severe enough to interrupt the recoding, then the most severe |
| 2195 |
error is retained, while others are forgotten(2). So, in case of an |
| 2196 |
error, the possible actions currently are: |
| 2197 |
|
| 2198 |
• do nothing and let go, returning success at end of recoding, |
| 2199 |
• just let go for now, but return failure at end of recoding, |
| 2200 |
• interrupt recoding right away and return failure now. |
| 2201 |
|
| 2202 |
*Note Task level::, and particularly the description of the fields |
| 2203 |
‘fail_level’, ‘abort_level’ and ‘error_so_far’, for more information |
| 2204 |
about how errors are handled. |
| 2205 |
|
| 2206 |
---------- Footnotes ---------- |
| 2207 |
|
| 2208 |
(1) The minimality of an ‘UTF-8’ encoding is guaranteed on output, |
| 2209 |
but currently, it is not checked on input. |
| 2210 |
|
| 2211 |
(2) Another approach would have been to define the level symbols as |
| 2212 |
masks instead, and to give masks to threshold setting routines, and to |
| 2213 |
retain all errors--yet I never met myself such a need in practice, and |
| 2214 |
so I fear it would be overkill. On the other hand, it might be |
| 2215 |
interesting to maintain counters about how many times each kind of error |
| 2216 |
occurred. |
| 2217 |
|
| 2218 |
|
| 2219 |
File: recode.info, Node: Universal, Next: iconv, Prev: Library, Up: Top |
| 2220 |
|
| 2221 |
5 The universal charset |
| 2222 |
*********************** |
| 2223 |
|
| 2224 |
Standard ISO 10646 defines a universal character set, intended to |
| 2225 |
encompass in the long run all languages written on this planet. It is |
| 2226 |
based on wide characters, and offer possibilities for two billion |
| 2227 |
characters (2^31). |
| 2228 |
|
| 2229 |
This charset was to become available in Recode under the name ‘UCS’, |
| 2230 |
with many external surfaces for it. But in the current version, only |
| 2231 |
surfaces of ‘UCS’ are offered, each presented as a genuine charset |
| 2232 |
rather than a surface. Such surfaces are only meaningful for the ‘UCS’ |
| 2233 |
charset, so it is not that useful to draw a line between the surfaces |
| 2234 |
and the only charset to which they may apply. |
| 2235 |
|
| 2236 |
‘UCS’ stands for Universal Character Set. ‘UCS-2’ and ‘UCS-4’ are |
| 2237 |
fixed length encodings, using two or four bytes per character |
| 2238 |
respectively. ‘UTF’ stands for ‘UCS’ Transformation Format, and are |
| 2239 |
variable length encodings dedicated to ‘UCS’. ‘UTF-1’ was based on |
| 2240 |
ISO 2022, it did not succeed(1). ‘UTF-2’ replaced it, it has been |
| 2241 |
called ‘UTF-FSS’ (File System Safe) in Unicode or Plan9 context, but is |
| 2242 |
better known today as ‘UTF-8’. To complete the picture, there is |
| 2243 |
‘UTF-16’ based on 16 bits bytes, and ‘UTF-7’ which is meant for |
| 2244 |
transmissions limited to 7-bit bytes. Most often, one might see ‘UTF-8’ |
| 2245 |
used for external storage, and ‘UCS-2’ used for internal storage. |
| 2246 |
|
| 2247 |
When Recode is producing any representation of ‘UCS’, it uses the |
| 2248 |
replacement character ‘U+FFFD’ for any _valid_ character which is not |
| 2249 |
representable in the goal charset(2). This happens, for example, when |
| 2250 |
‘UCS-2’ is not capable to echo a wide ‘UCS-4’ character, or for a |
| 2251 |
similar reason, an ‘UTF-8’ sequence using more than three bytes. The |
| 2252 |
replacement character is meant to represent an existing character. So, |
| 2253 |
it is never produced to represent an invalid sequence or ill-formed |
| 2254 |
character in the input text. In such cases, Recode just gets rid of the |
| 2255 |
noise, while taking note of the error in its usual ways. |
| 2256 |
|
| 2257 |
Even if ‘UTF-8’ is an encoding, really, it is the encoding of a |
| 2258 |
single character set, and nothing else. It is useful to distinguish |
| 2259 |
between an encoding (a _surface_ within Recode) and a charset, but only |
| 2260 |
when the surface may be applied to several charsets. Specifying a |
| 2261 |
charset is a bit simpler than specifying a surface in a Recode request. |
| 2262 |
There would not be a practical advantage at imposing a more complex |
| 2263 |
syntax to Recode users, when it is simple to assimilate ‘UTF-8’ to a |
| 2264 |
charset. Similar considerations apply for ‘UCS-2’, ‘UCS-4’, ‘UTF-16’ |
| 2265 |
and ‘UTF-7’. These are all considered to be charsets. |
| 2266 |
|
| 2267 |
* Menu: |
| 2268 |
|
| 2269 |
* UCS-2:: Universal Character Set, 2 bytes |
| 2270 |
* UCS-4:: Universal Character Set, 4 bytes |
| 2271 |
* UTF-7:: Universal Transformation Format, 7 bits |
| 2272 |
* UTF-8:: Universal Transformation Format, 8 bits |
| 2273 |
* UTF-16:: Universal Transformation Format, 16 bits |
| 2274 |
* count-characters:: Frequency count of characters |
| 2275 |
* dump-with-names:: Fully interpreted UCS dump |
| 2276 |
|
| 2277 |
---------- Footnotes ---------- |
| 2278 |
|
| 2279 |
(1) It is not probable that Recode will ever support ‘UTF-1’. |
| 2280 |
|
| 2281 |
(2) This is when the goal charset allows for 16-bits. For shorter |
| 2282 |
charsets, the ‘--strict’ (‘-s’) option decides what happens: either the |
| 2283 |
character is dropped, or a reversible mapping is produced on the fly. |
| 2284 |
|
| 2285 |
|
| 2286 |
File: recode.info, Node: UCS-2, Next: UCS-4, Prev: Universal, Up: Universal |
| 2287 |
|
| 2288 |
5.1 Universal Character Set, 2 bytes |
| 2289 |
==================================== |
| 2290 |
|
| 2291 |
One surface of ‘UCS’ is usable for the subset defined by its first sixty |
| 2292 |
thousand characters (in fact, 31 * 2^11 codes), and uses exactly two |
| 2293 |
bytes per character. It is a mere dump of the internal memory |
| 2294 |
representation which is _natural_ for this subset and as such, conveys |
| 2295 |
with it endianness problems. |
| 2296 |
|
| 2297 |
A non-empty ‘UCS-2’ file normally begins with a so called “byte order |
| 2298 |
mark”, having value ‘0xFEFF’. The value ‘0xFFFE’ is not an ‘UCS’ |
| 2299 |
character, so if this value is seen at the beginning of a file, Recode |
| 2300 |
reacts by swapping all pairs of bytes. The library also properly reacts |
| 2301 |
to other occurrences of ‘0xFEFF’ or ‘0xFFFE’ elsewhere than at the |
| 2302 |
beginning, because concatenation of ‘UCS-2’ files should stay a simple |
| 2303 |
matter, but it might trigger a diagnostic about non canonical input. |
| 2304 |
|
| 2305 |
By default, when producing an ‘UCS-2’ file, Recode always outputs the |
| 2306 |
high order byte before the low order byte. Note that this may not be |
| 2307 |
the case if ‘iconv’ is used; in that case, you may be able to use the |
| 2308 |
charset ‘UCS-2BE’ to specify big-endian UCS-2. The order can also be |
| 2309 |
easily overridden through the ‘21-Permutation’ surface (*note |
| 2310 |
Permutations::). For example, the command: |
| 2311 |
|
| 2312 |
recode u8..u2/21 < INPUT > OUTPUT |
| 2313 |
|
| 2314 |
asks for an ‘UTF-8’ to ‘UCS-2’ conversion, with swapped byte output. |
| 2315 |
|
| 2316 |
Use ‘UCS-2’ as a genuine charset. This charset is available in |
| 2317 |
Recode under the name ‘ISO-10646-UCS-2’. Accepted aliases are ‘UCS-2’, |
| 2318 |
‘BMP’, ‘rune’ and ‘u2’. |
| 2319 |
|
| 2320 |
The Recode library is able to combine ‘UCS-2’ some sequences of codes |
| 2321 |
into single code characters, to represent a few diacriticized |
| 2322 |
characters, ligatures or diphtongs which have been included to ease |
| 2323 |
mapping with other existing charsets. It is also able to explode such |
| 2324 |
single code characters into the corresponding sequence of codes. The |
| 2325 |
request syntax for triggering such operations is rudimentary and |
| 2326 |
temporary. The ‘combined-UCS-2’ pseudo character set is a special form |
| 2327 |
of ‘UCS-2’ in which known combinings have been replaced by the simpler |
| 2328 |
code. Using ‘combined-UCS-2’ instead of ‘UCS-2’ in an _after_ position |
| 2329 |
of a request forces a combining step, while using ‘combined-UCS-2’ |
| 2330 |
instead of ‘UCS-2’ in a _before_ position of a request forces an |
| 2331 |
exploding step. For the time being, one has to resort to advanced |
| 2332 |
request syntax to achieve other effects. For example: |
| 2333 |
|
| 2334 |
recode u8..co,u2..u8 < INPUT > OUTPUT |
| 2335 |
|
| 2336 |
copies an ‘UTF-8’ INPUT over OUTPUT, still to be in ‘UTF-8’, yet merging |
| 2337 |
combining characters into single codes whenever possible. |
| 2338 |
|
| 2339 |
|
| 2340 |
File: recode.info, Node: UCS-4, Next: UTF-7, Prev: UCS-2, Up: Universal |
| 2341 |
|
| 2342 |
5.2 Universal Character Set, 4 bytes |
| 2343 |
==================================== |
| 2344 |
|
| 2345 |
Another surface of ‘UCS’ uses exactly four bytes per character, and is a |
| 2346 |
mere dump of the internal memory representation which is _natural_ for |
| 2347 |
the whole charset and as such, conveys with it endianness problems. |
| 2348 |
|
| 2349 |
Use it as a genuine charset. This charset is available in Recode |
| 2350 |
under the name ‘ISO-10646-UCS-4’. Accepted aliases are ‘UCS’, ‘UCS-4’, |
| 2351 |
‘ISO_10646’, ‘10646’ and ‘u4’. |
| 2352 |
|
| 2353 |
|
| 2354 |
File: recode.info, Node: UTF-7, Next: UTF-8, Prev: UCS-4, Up: Universal |
| 2355 |
|
| 2356 |
5.3 Universal Transformation Format, 7 bits |
| 2357 |
=========================================== |
| 2358 |
|
| 2359 |
‘UTF-7’ comes from IETF rather than ISO, and is described by RFC 2152, |
| 2360 |
in the MIME series. The ‘UTF-7’ encoding is meant to fit ‘UCS-2’ over |
| 2361 |
channels limited to seven bits per byte. It proceeds from a mix between |
| 2362 |
the spirit of ‘Quoted-Printable’ and methods of ‘Base64’, adapted to |
| 2363 |
Unicode contexts. |
| 2364 |
|
| 2365 |
This charset is available in Recode under the name |
| 2366 |
‘UNICODE-1-1-UTF-7’. Accepted aliases are ‘UTF-7’, ‘TF-7’ and ‘u7’. |
| 2367 |
|
| 2368 |
|
| 2369 |
File: recode.info, Node: UTF-8, Next: UTF-16, Prev: UTF-7, Up: Universal |
| 2370 |
|
| 2371 |
5.4 Universal Transformation Format, 8 bits |
| 2372 |
=========================================== |
| 2373 |
|
| 2374 |
Even if ‘UTF-8’ does not originally come from IETF, there is now |
| 2375 |
RFC 2279 to describe it. In letters sent on 1995-01-21 and 1995-04-20, |
| 2376 |
Markus Kuhn writes: |
| 2377 |
|
| 2378 |
‘UTF-8’ is an ‘ASCII’ compatible multi-byte encoding of the |
| 2379 |
ISO 10646 universal character set (‘UCS’). ‘UCS’ is a 31-bit |
| 2380 |
superset of all other character set standards. The first 256 |
| 2381 |
characters of ‘UCS’ are identical to those of ISO 8859-1 (Latin-1). |
| 2382 |
The ‘UCS-2’ encoding of UCS is a sequence of bigendian 16-bit |
| 2383 |
words, the ‘UCS-4’ encoding is a sequence of bigendian 32-bit |
| 2384 |
words. The ‘UCS-2’ subset of ISO 10646 is also known as "Unicode". |
| 2385 |
As both ‘UCS-2’ and ‘UCS-4’ require heavy modifications to |
| 2386 |
traditional ‘ASCII’ oriented system designs (e.g. Unix), the |
| 2387 |
‘UTF-8’ encoding has been designed for these applications. |
| 2388 |
|
| 2389 |
In ‘UTF-8’, only ‘ASCII’ characters are encoded using bytes below |
| 2390 |
128. All other non-ASCII characters are encoded as multi-byte |
| 2391 |
sequences consisting only of bytes in the range 128-253. This |
| 2392 |
avoids critical bytes like ‘NUL’ and ‘/’ in ‘UTF-8’ strings, which |
| 2393 |
makes the ‘UTF-8’ encoding suitable for being handled by the |
| 2394 |
standard C string library and being used in Unix file names. Other |
| 2395 |
properties include the preserved lexical sorting order and that |
| 2396 |
‘UTF-8’ allows easy self-synchronisation of software receiving |
| 2397 |
‘UTF-8’ strings. |
| 2398 |
|
| 2399 |
‘UTF-8’ is the most common external surface of ‘UCS’, each character |
| 2400 |
uses from one to six bytes, and is able to encode all 2^31 characters of |
| 2401 |
the ‘UCS’. It is implemented as a charset, with the following |
| 2402 |
properties: |
| 2403 |
|
| 2404 |
• Strict 7-bit ‘ASCII’ is completely invariant under ‘UTF-8’, and |
| 2405 |
those are the only one-byte characters. ‘UCS’ values and ‘ASCII’ |
| 2406 |
values coincide. No multi-byte characters ever contain bytes less |
| 2407 |
than 128. ‘NUL’ _is_ ‘NUL’. A multi-byte character always starts |
| 2408 |
with a byte of 192 or more, and is always followed by a number of |
| 2409 |
bytes between 128 to 191. That means that you may read at random |
| 2410 |
on disk or memory, and easily discover the start of the current, |
| 2411 |
next or previous character. You can count, skip or extract |
| 2412 |
characters with this only knowledge. |
| 2413 |
|
| 2414 |
• If you read the first byte of a multi-byte character in binary, it |
| 2415 |
contains many ‘1’ bits in successions starting with the most |
| 2416 |
significant one (from the left), at least two. The length of this |
| 2417 |
‘1’ sequence equals the byte size of the character. All succeeding |
| 2418 |
bytes start by ‘10’. This is a lot of redundancy, making it fairly |
| 2419 |
easy to guess that a file is valid ‘UTF-8’, or to safely state that |
| 2420 |
it is not. |
| 2421 |
|
| 2422 |
• In a multi-byte character, if you remove all leading ‘1’ bits of |
| 2423 |
the first byte of a multi-byte character, and the initial ‘10’ bits |
| 2424 |
of all remaining bytes (so keeping 6 bits per byte for those), the |
| 2425 |
remaining bits concatenated are the UCS value. |
| 2426 |
|
| 2427 |
These properties also have a few nice consequences: |
| 2428 |
|
| 2429 |
• Conversion to/from values is algorithmically simple, and reasonably |
| 2430 |
speedy. |
| 2431 |
|
| 2432 |
• A sequence of N bytes can hold characters needing up to 2 + 5N bits |
| 2433 |
in their ‘UCS’ representation. Here, N is a number between 1 and |
| 2434 |
6. So, ‘UTF-8’ is most economical when mapping ASCII (1 byte), |
| 2435 |
followed by ‘UCS-2’ (1 to 3 bytes) and ‘UCS-4’ (1 to 6 bytes). |
| 2436 |
|
| 2437 |
• The lexicographic sorting order of ‘UCS’ strings is preserved. |
| 2438 |
|
| 2439 |
• Bytes with value 254 or 255 never appear, and because of that, |
| 2440 |
these are sometimes used when escape mechanisms are needed. |
| 2441 |
|
| 2442 |
In some case, when little processing is done on a lot of strings, one |
| 2443 |
may choose for efficiency reasons to handle ‘UTF-8’ strings directly |
| 2444 |
even if variable length, as it is easy to get start of characters. |
| 2445 |
Character insertion or replacement might require moving the remainder of |
| 2446 |
the string in either direction. In most cases, it is faster and easier |
| 2447 |
to convert from ‘UTF-8’ to ‘UCS-2’ or ‘UCS-4’ prior to processing. |
| 2448 |
|
| 2449 |
This charset is available in Recode under the name ‘UTF-8’. Accepted |
| 2450 |
aliases are ‘UTF-2’, ‘UTF-FSS’, ‘FSS_UTF’, ‘TF-8’ and ‘u8’. |
| 2451 |
|
| 2452 |
|
| 2453 |
File: recode.info, Node: UTF-16, Next: count-characters, Prev: UTF-8, Up: Universal |
| 2454 |
|
| 2455 |
5.5 Universal Transformation Format, 16 bits |
| 2456 |
============================================ |
| 2457 |
|
| 2458 |
Another external surface of ‘UCS’ is also variable length, each |
| 2459 |
character using either two or four bytes. It is usable for the subset |
| 2460 |
defined by the first million characters (17 * 2^16) of ‘UCS’. |
| 2461 |
|
| 2462 |
Martin J. Dürst writes (to <comp.std.internat>, on 1995-03-28): |
| 2463 |
|
| 2464 |
‘UTF-16’ is another method that reserves two times 1024 codepoints |
| 2465 |
in Unicode and uses them to index around one million additional |
| 2466 |
characters. ‘UTF-16’ is a little bit like former multibyte codes, |
| 2467 |
but quite not so, as both the first and the second 16-bit code |
| 2468 |
clearly show what they are. The idea is that one million |
| 2469 |
codepoints should be enough for all the rare Chinese ideograms and |
| 2470 |
historical scripts that do not fit into the Base Multilingual Plane |
| 2471 |
of ISO 10646 (with just about 63,000 positions available, now that |
| 2472 |
2,000 are gone). |
| 2473 |
|
| 2474 |
This charset is available in Recode under the name ‘UTF-16’. |
| 2475 |
Accepted aliases are ‘Unicode’, ‘TF-16’ and ‘u6’. |
| 2476 |
|
| 2477 |
|
| 2478 |
File: recode.info, Node: count-characters, Next: dump-with-names, Prev: UTF-16, Up: Universal |
| 2479 |
|
| 2480 |
5.6 Frequency count of characters |
| 2481 |
================================= |
| 2482 |
|
| 2483 |
A device may be used to obtain a list of characters in a file, and how |
| 2484 |
many times each character appears. Each count is followed by the |
| 2485 |
‘UCS-2’ value of the character and, when known, the RFC 1345 mnemonic |
| 2486 |
for that character. |
| 2487 |
|
| 2488 |
This charset is available in Recode under the name |
| 2489 |
‘count-characters’. |
| 2490 |
|
| 2491 |
This ‘count’ feature has been implemented as a charset. This may |
| 2492 |
change in some later version, as it would sometimes be convenient to |
| 2493 |
count original bytes, instead of their ‘UCS-2’ equivalent. |
| 2494 |
|
| 2495 |
|
| 2496 |
File: recode.info, Node: dump-with-names, Prev: count-characters, Up: Universal |
| 2497 |
|
| 2498 |
5.7 Fully interpreted UCS dump |
| 2499 |
============================== |
| 2500 |
|
| 2501 |
Another device may be used to get fully interpreted dumps of an ‘UCS-2’ |
| 2502 |
stream of characters, with one ‘UCS-2’ character displayed on a full |
| 2503 |
output line. Each line receives the RFC 1345 mnemonic for the character |
| 2504 |
if it exists, the ‘UCS-2’ value of the character, and a descriptive |
| 2505 |
comment for that character. As each input character produces its own |
| 2506 |
output line, beware that the output file from this conversion may be |
| 2507 |
much, much bigger than the input file. |
| 2508 |
|
| 2509 |
This charset is available in Recode under the name ‘dump-with-names’. |
| 2510 |
|
| 2511 |
This ‘dump-with-names’ feature has been implemented as a charset |
| 2512 |
rather than a surface. This is surely debatable. The current |
| 2513 |
implementation allows for dumping charsets other than ‘UCS-2’. For |
| 2514 |
example, the command ‘recode l2..full < INPUT’ implies a necessary |
| 2515 |
conversion from ‘Latin-2’ to ‘UCS-2’, as ‘dump-with-names’ is only |
| 2516 |
connected out from ‘UCS-2’. In such cases, Recode does not display the |
| 2517 |
original ‘Latin-2’ codes in the dump, only the corresponding ‘UCS-2’ |
| 2518 |
values. To give a simpler example, the command |
| 2519 |
|
| 2520 |
echo 'Hello, world!' | recode us..dump |
| 2521 |
|
| 2522 |
produces the following output: |
| 2523 |
|
| 2524 |
UCS2 Mne Description |
| 2525 |
|
| 2526 |
0048 H latin capital letter h |
| 2527 |
0065 e latin small letter e |
| 2528 |
006C l latin small letter l |
| 2529 |
006C l latin small letter l |
| 2530 |
006F o latin small letter o |
| 2531 |
002C , comma |
| 2532 |
0020 SP space |
| 2533 |
0077 w latin small letter w |
| 2534 |
006F o latin small letter o |
| 2535 |
0072 r latin small letter r |
| 2536 |
006C l latin small letter l |
| 2537 |
0064 d latin small letter d |
| 2538 |
0021 ! exclamation mark |
| 2539 |
000A LF line feed (lf) |
| 2540 |
|
| 2541 |
The descriptive comment is given in English and ‘ASCII’, yet if the |
| 2542 |
English description is not available but a French one is, then the |
| 2543 |
French description is given instead, using ‘Latin-1’. However, if the |
| 2544 |
‘LC_MESSAGES’ environment variable begins with the letters ‘fr’, then |
| 2545 |
listing preference goes to French when both descriptions are available. |
| 2546 |
|
| 2547 |
Here is another example. To get the long description of the code 237 |
| 2548 |
in Latin-5 table, one may use the following command. |
| 2549 |
|
| 2550 |
echo -n 237 | recode l5/d..dump |
| 2551 |
|
| 2552 |
If your ‘echo’ does not grok ‘-n’, use ‘echo 237\c’ instead. Here is |
| 2553 |
how to see what Unicode ‘U+03C6’ means, while getting rid of the title |
| 2554 |
lines. |
| 2555 |
|
| 2556 |
echo -n 0x03C6 | recode u2/x2..dump | tail +3 |
| 2557 |
|
| 2558 |
|
| 2559 |
File: recode.info, Node: iconv, Next: Tabular, Prev: Universal, Up: Top |
| 2560 |
|
| 2561 |
6 The ‘iconv’ library |
| 2562 |
********************* |
| 2563 |
|
| 2564 |
The Recode library is able to use the capabilities of an external, |
| 2565 |
pre-installed ‘iconv’ library, usually as provided by GNU ‘libc’ or the |
| 2566 |
portable ‘libiconv’ written by Bruno Haible. In fact, many capabilities |
| 2567 |
of the Recode library are duplicated in an external ‘iconv’ library, as |
| 2568 |
they likely share many charsets. We discuss, here, the issues related |
| 2569 |
to this duplication, and other peculiarities specific to the ‘iconv’ |
| 2570 |
library. |
| 2571 |
|
| 2572 |
The ‘RECODE_STRICT_MAPPING_FLAG’ option, corresponding to the |
| 2573 |
‘--strict’ flag, is implemented by adding ‘iconv’ option ‘//IGNORE’ to |
| 2574 |
the ‘after’ encoding. This has the side effect that untranslatable |
| 2575 |
input is only signalled at the end of the conversion, whereas with |
| 2576 |
Recode's built-in conversion routines the error will be signalled |
| 2577 |
immediately. |
| 2578 |
|
| 2579 |
If the string ‘-translit’ is appended to the AFTER encoding, |
| 2580 |
characters being converted are transliterated when needed and possible. |
| 2581 |
This means that when a character cannot be represented in the target |
| 2582 |
character set, it can be approximated through one or several similar |
| 2583 |
looking characters. Characters that are outside of the target character |
| 2584 |
set and cannot be transliterated are replaced with a question mark (?) |
| 2585 |
in the output. This corresponds to the ‘iconv’ option ‘//TRANSLIT’. |
| 2586 |
|
| 2587 |
To check whether ‘iconv’ is used for a particular conversion, just |
| 2588 |
use the ‘-v’ or ‘--verbose’ option, *note Recoding::, and check whether |
| 2589 |
‘:iconv:’ appears as an intermediate charset. |
| 2590 |
|
| 2591 |
The ‘:iconv:’ charset represents a conceptual pivot charset within |
| 2592 |
the external ‘iconv’ library (in fact, this pivot exists, but is not |
| 2593 |
directly reachable). This charset has a ‘:’ (a mere colon) and |
| 2594 |
‘:libiconv:’ for aliases. It is not allowed to recode from or to this |
| 2595 |
charset directly. But when this charset is selected as an intermediate, |
| 2596 |
usually by automatic means, then the external ‘iconv’ Recode library is |
| 2597 |
called to handle the transformations. By using an ‘--ignore=:iconv:’ |
| 2598 |
option on the ‘recode’ call or equivalently, but more simply, ‘-x:’, |
| 2599 |
Recode is instructed to avoid this charset as an intermediate, with the |
| 2600 |
consequence that the external ‘iconv’ library is not used. You can also |
| 2601 |
use ‘--prefer-iconv’ to use ‘iconv’ if possible. Consider these calls: |
| 2602 |
|
| 2603 |
recode l1..1250 < INPUT > OUTPUT |
| 2604 |
recode -x: l1..1250 < INPUT > OUTPUT |
| 2605 |
recode --prefer-iconv l1..1250 < INPUT > OUTPUT |
| 2606 |
|
| 2607 |
All should transform INPUT from ‘ISO-8859-1’ to ‘CP1250’ on OUTPUT. The |
| 2608 |
first call might use the external ‘iconv’ library, while the second call |
| 2609 |
definitely avoids it. The third call will use the external ‘iconv’ |
| 2610 |
library if it supports the required conversion. Whatever the path used, |
| 2611 |
the results should normally be identical. However, there might be |
| 2612 |
observable differences. Most of them might result from reversibility |
| 2613 |
issues, as the external ‘iconv’ engine does not likely address |
| 2614 |
reversibility in the same way. Even if much less likely, some |
| 2615 |
differences might result from slight errors in the tables used, such |
| 2616 |
differences should then be reported as bugs. |
| 2617 |
|
| 2618 |
Discrepancies might be seen in the area of error detection and |
| 2619 |
recovery. The Recode library usually tries to detect canonicity errors |
| 2620 |
in input, and production of ambiguous output, but the external ‘iconv’ |
| 2621 |
library does not necessarily do it the same way. Moreover, the Recode |
| 2622 |
library may not always recover as nicely as possible when the external |
| 2623 |
‘iconv’ has no translation for a given character. |
| 2624 |
|
| 2625 |
The external ‘iconv’ libraries may offer different sets of charsets |
| 2626 |
and aliases from one library to another, and also between successive |
| 2627 |
versions of a single library. Best is to check the documentation of the |
| 2628 |
external ‘iconv’ library, as of the time Recode was installed, to know |
| 2629 |
which charsets and aliases are being provided. |
| 2630 |
|
| 2631 |
The ‘--ignore=:iconv:’ or ‘-x:’ options might be useful when there is |
| 2632 |
a need to make a recoding more exactly repeatable between machines or |
| 2633 |
installations, the idea being here to remove the variance possibly |
| 2634 |
introduced by the various implementations of an external ‘iconv’ |
| 2635 |
library. These options might also help deciding whether if some |
| 2636 |
recoding problem is genuine to Recode, or is induced by the external |
| 2637 |
‘iconv’ library. |
| 2638 |
|
| 2639 |
|
| 2640 |
File: recode.info, Node: Tabular, Next: ASCII misc, Prev: iconv, Up: Top |
| 2641 |
|
| 2642 |
7 Tabular sources (RFC 1345) |
| 2643 |
**************************** |
| 2644 |
|
| 2645 |
An important part of the tabular charset knowledge in Recode comes from |
| 2646 |
RFC 1345 or, alternatively, from the ‘chset’ tools, both maintained by |
| 2647 |
Keld Simonsen. The RFC 1345 document: |
| 2648 |
|
| 2649 |
"Character Mnemonics & Character Sets", K. Simonsen, Request for |
| 2650 |
Comments no. 1345, Network Working Group, June 1992. |
| 2651 |
|
| 2652 |
defines many character mnemonics and character sets. The Recode library |
| 2653 |
implements most of RFC 1345, however: |
| 2654 |
|
| 2655 |
• It does not recognise those charsets which overload character |
| 2656 |
positions: ‘dk-us’ and ‘us-dk’. However, *Note Mixed::. |
| 2657 |
|
| 2658 |
• It does not recognise those charsets which combine two characters |
| 2659 |
for representing a third: ‘ANSI_X3.110-1983’, ‘ISO_6937-2-add’, |
| 2660 |
‘T.101-G2’, ‘T.61-8bit’, ‘iso-ir-90’ and ‘videotex-suppl’. |
| 2661 |
|
| 2662 |
• It does not recognise 16-bits charsets: ‘GB_2312-80’, |
| 2663 |
‘JIS_C6226-1978’, ‘JIS_C6226-1983’, ‘JIS_X0212-1990’ and |
| 2664 |
‘KS_C_5601-1987’. |
| 2665 |
|
| 2666 |
• It interprets the charset ‘isoir91’ as ‘NATS-DANO’ (alias |
| 2667 |
‘iso-ir-9-1’), _not_ as ‘JIS_C6229-1984-a’ (alias ‘iso-ir-91’). It |
| 2668 |
also interprets the charset ‘isoir92’ as ‘NATS-DANO-ADD’ (alias |
| 2669 |
‘iso-ir-9-2’), _not_ as ‘JIS_C6229-1984-b’ (alias ‘iso-ir-92’). It |
| 2670 |
might be better just avoiding these two alias names. |
| 2671 |
|
| 2672 |
Keld Simonsen <[email protected]> did most of RFC 1345 himself, with some |
| 2673 |
funding from Danish Standards and Nordic standards (INSTA) project. He |
| 2674 |
also did the character set design work, with substantial input from Olle |
| 2675 |
Jaernefors. Keld typed in almost all of the tables, some have been |
| 2676 |
contributed. A number of people have checked the tables in various |
| 2677 |
ways. The RFC lists a number of people who helped. |
| 2678 |
|
| 2679 |
Keld and the Recode maintainer have an arrangement by which any new |
| 2680 |
discovered information submitted by Recode users, about tabular |
| 2681 |
charsets, is forwarded to Keld, eventually merged into Keld's work, and |
| 2682 |
only then, reimported into Recode. Recode does not try to compete, nor |
| 2683 |
even establish itself as an alternate or diverging reference: RFC 1345 |
| 2684 |
and its new drafts stay the genuine source for most tabular information |
| 2685 |
conveyed by Recode. Keld has been more than collaborative so far, so |
| 2686 |
there is no reason that we act otherwise. In a word, Recode should be |
| 2687 |
perceived as the application of external references, but not as a |
| 2688 |
reference in itself. |
| 2689 |
|
| 2690 |
Internally, RFC 1345 associates which each character an unambiguous |
| 2691 |
mnemonic of a few characters, taken from ISO 646, which is a minimal |
| 2692 |
ASCII subset of 83 characters. The charset made up by these mnemonics |
| 2693 |
is available in Recode under the name ‘RFC1345’. It has ‘mnemonic’ and |
| 2694 |
‘1345’ for aliases. As implemened, this charset exactly corresponds to |
| 2695 |
‘mnemonic+ascii+38’, using RFC 1345 nomenclature. Roughly said, ISO 646 |
| 2696 |
characters represent themselves, except for the ampersand (‘&’) which |
| 2697 |
appears doubled. A prefix of a single ampersand introduces a mnemonic. |
| 2698 |
For mnemonics using two characters, the prefix is immediately by the |
| 2699 |
mnemonic. For longer mnemonics, the prefix is followed by an underline |
| 2700 |
(‘_’), the mmemonic, and another underline. Conversions to this charset |
| 2701 |
are usually reversible. |
| 2702 |
|
| 2703 |
Currently, Recode does not offer any of the many other possible |
| 2704 |
variations of this family of representations. |
| 2705 |
|
| 2706 |
‘ANSI_X3.4-1968’ |
| 2707 |
‘367’, ‘ANSI_X3.4-1986’, ‘ASCII’, ‘CP367’, ‘IBM367’, ‘ISO646-US’, |
| 2708 |
‘ISO_646.irv:1991’, ‘US-ASCII’, ‘iso-ir-6’ and ‘us’ are aliases for |
| 2709 |
this charset. Source: ISO 2375 registry. |
| 2710 |
|
| 2711 |
‘ASMO_449’ |
| 2712 |
‘ISO_9036’, ‘arabic7’ and ‘iso-ir-89’ are aliases for this charset. |
| 2713 |
Source: ISO 2375 registry. |
| 2714 |
|
| 2715 |
‘BS_4730’ |
| 2716 |
‘ISO646-GB’, ‘gb’, ‘iso-ir-4’ and ‘uk’ are aliases for this |
| 2717 |
charset. Source: ISO 2375 registry. |
| 2718 |
|
| 2719 |
‘BS_viewdata’ |
| 2720 |
‘iso-ir-47’ is an alias for this charset. Source: ISO 2375 |
| 2721 |
registry. |
| 2722 |
|
| 2723 |
‘CP1250’ |
| 2724 |
‘1250’, ‘ms-ee’ and ‘windows-1250’ are aliases for this charset. |
| 2725 |
Source: UNICODE 1.0. |
| 2726 |
|
| 2727 |
‘CP1251’ |
| 2728 |
‘1251’, ‘ms-cyrl’ and ‘windows-1251’ are aliases for this charset. |
| 2729 |
Source: UNICODE 1.0. |
| 2730 |
|
| 2731 |
‘CP1252’ |
| 2732 |
‘1252’, ‘ms-ansi’ and ‘windows-1252’ are aliases for this charset. |
| 2733 |
Source: UNICODE 1.0. |
| 2734 |
|
| 2735 |
‘CP1253’ |
| 2736 |
‘1253’, ‘ms-greek’ and ‘windows-1253’ are aliases for this charset. |
| 2737 |
Source: UNICODE 1.0. |
| 2738 |
|
| 2739 |
‘CP1254’ |
| 2740 |
‘1254’, ‘ms-turk’ and ‘windows-1254’ are aliases for this charset. |
| 2741 |
Source: UNICODE 1.0. |
| 2742 |
|
| 2743 |
‘CP1255’ |
| 2744 |
‘1255’, ‘ms-hebr’ and ‘windows-1255’ are aliases for this charset. |
| 2745 |
Source: UNICODE 1.0. |
| 2746 |
|
| 2747 |
‘CP1256’ |
| 2748 |
‘1256’, ‘ms-arab’ and ‘windows-1256’ are aliases for this charset. |
| 2749 |
Source: UNICODE 1.0. |
| 2750 |
|
| 2751 |
‘CP1257’ |
| 2752 |
‘1257’, ‘WinBaltRim’ and ‘windows-1257’ are aliases for this |
| 2753 |
charset. Source: CEN/TC304 N283. |
| 2754 |
|
| 2755 |
‘CSA_Z243.4-1985-1’ |
| 2756 |
‘ISO646-CA’, ‘ca’, ‘csa7-1’ and ‘iso-ir-121’ are aliases for this |
| 2757 |
charset. Source: ISO 2375 registry. |
| 2758 |
|
| 2759 |
‘CSA_Z243.4-1985-2’ |
| 2760 |
‘ISO646-CA2’, ‘csa7-2’ and ‘iso-ir-122’ are aliases for this |
| 2761 |
charset. Source: ISO 2375 registry. |
| 2762 |
|
| 2763 |
‘CSA_Z243.4-1985-gr’ |
| 2764 |
‘iso-ir-123’ is an alias for this charset. Source: ISO 2375 |
| 2765 |
registry. |
| 2766 |
|
| 2767 |
‘CSN_369103’ |
| 2768 |
‘KOI-8_L2’, ‘iso-ir-139’ and ‘koi8l2’ are aliases for this charset. |
| 2769 |
Source: ISO 2375 registry. |
| 2770 |
|
| 2771 |
‘CWI’ |
| 2772 |
‘CWI-2’ and ‘cp-hu’ are aliases for this charset. Source: |
| 2773 |
Computerworld Sza'mita'stechnika vol 3 issue 13 1988-06-29. |
| 2774 |
|
| 2775 |
‘DEC-MCS’ |
| 2776 |
‘dec’ is an alias for this charset. VAX/VMS User's Manual, Order |
| 2777 |
Number: AI-Y517A-TE, April 1986. |
| 2778 |
|
| 2779 |
‘DIN_66003’ |
| 2780 |
‘ISO646-DE’, ‘de’ and ‘iso-ir-21’ are aliases for this charset. |
| 2781 |
Source: ISO 2375 registry. |
| 2782 |
|
| 2783 |
‘DS_2089’ |
| 2784 |
‘DS2089’, ‘ISO646-DK’ and ‘dk’ are aliases for this charset. |
| 2785 |
Source: Danish Standard, DS 2089, February 1974. |
| 2786 |
|
| 2787 |
‘EBCDIC-AT-DE’ |
| 2788 |
Source: IBM 3270 Char Set Ref Ch 10, GA27-2837-9, April 1987. |
| 2789 |
|
| 2790 |
‘EBCDIC-AT-DE-A’ |
| 2791 |
Source: IBM 3270 Char Set Ref Ch 10, GA27-2837-9, April 1987. |
| 2792 |
|
| 2793 |
‘EBCDIC-CA-FR’ |
| 2794 |
Source: IBM 3270 Char Set Ref Ch 10, GA27-2837-9, April 1987. |
| 2795 |
|
| 2796 |
‘EBCDIC-DK-NO’ |
| 2797 |
Source: IBM 3270 Char Set Ref Ch 10, GA27-2837-9, April 1987. |
| 2798 |
|
| 2799 |
‘EBCDIC-DK-NO-A’ |
| 2800 |
Source: IBM 3270 Char Set Ref Ch 10, GA27-2837-9, April 1987. |
| 2801 |
|
| 2802 |
‘EBCDIC-ES’ |
| 2803 |
Source: IBM 3270 Char Set Ref Ch 10, GA27-2837-9, April 1987. |
| 2804 |
|
| 2805 |
‘EBCDIC-ES-A’ |
| 2806 |
Source: IBM 3270 Char Set Ref Ch 10, GA27-2837-9, April 1987. |
| 2807 |
|
| 2808 |
‘EBCDIC-ES-S’ |
| 2809 |
Source: IBM 3270 Char Set Ref Ch 10, GA27-2837-9, April 1987. |
| 2810 |
|
| 2811 |
‘EBCDIC-FI-SE’ |
| 2812 |
Source: IBM 3270 Char Set Ref Ch 10, GA27-2837-9, April 1987. |
| 2813 |
|
| 2814 |
‘EBCDIC-FI-SE-A’ |
| 2815 |
Source: IBM 3270 Char Set Ref Ch 10, GA27-2837-9, April 1987. |
| 2816 |
|
| 2817 |
‘EBCDIC-FR’ |
| 2818 |
Source: IBM 3270 Char Set Ref Ch 10, GA27-2837-9, April 1987. |
| 2819 |
|
| 2820 |
‘EBCDIC-IS-FRISS’ |
| 2821 |
‘friss’ is an alias for this charset. Source: Skyrsuvelar Rikisins |
| 2822 |
og Reykjavikurborgar, feb 1982. |
| 2823 |
|
| 2824 |
‘EBCDIC-IT’ |
| 2825 |
Source: IBM 3270 Char Set Ref Ch 10, GA27-2837-9, April 1987. |
| 2826 |
|
| 2827 |
‘EBCDIC-PT’ |
| 2828 |
Source: IBM 3270 Char Set Ref Ch 10, GA27-2837-9, April 1987. |
| 2829 |
|
| 2830 |
‘EBCDIC-UK’ |
| 2831 |
Source: IBM 3270 Char Set Ref Ch 10, GA27-2837-9, April 1987. |
| 2832 |
|
| 2833 |
‘EBCDIC-US’ |
| 2834 |
Source: IBM 3270 Char Set Ref Ch 10, GA27-2837-9, April 1987. |
| 2835 |
|
| 2836 |
‘ECMA-cyrillic’ |
| 2837 |
‘ECMA-113’, ‘ECMA-113:1986’ and ‘iso-ir-111’ are aliases for this |
| 2838 |
charset. Source: ISO 2375 registry. |
| 2839 |
|
| 2840 |
‘ES’ |
| 2841 |
‘ISO646-ES’ and ‘iso-ir-17’ are aliases for this charset. Source: |
| 2842 |
ISO 2375 registry. |
| 2843 |
|
| 2844 |
‘ES2’ |
| 2845 |
‘ISO646-ES2’ and ‘iso-ir-85’ are aliases for this charset. Source: |
| 2846 |
ISO 2375 registry. |
| 2847 |
|
| 2848 |
‘GB_1988-80’ |
| 2849 |
‘ISO646-CN’, ‘cn’ and ‘iso-ir-57’ are aliases for this charset. |
| 2850 |
Source: ISO 2375 registry. |
| 2851 |
|
| 2852 |
‘GOST_19768-87’ |
| 2853 |
‘ST_SEV_358-88’ and ‘iso-ir-153’ are aliases for this charset. |
| 2854 |
Source: ISO 2375 registry. |
| 2855 |
|
| 2856 |
‘IBM037’ |
| 2857 |
‘037’, ‘CP037’, ‘ebcdic-cp-ca’, ‘ebcdic-cp-nl’, ‘ebcdic-cp-us’ and |
| 2858 |
‘ebcdic-cp-wt’ are aliases for this charset. Source: IBM NLS RM |
| 2859 |
Vol2 SE09-8002-01, March 1990. |
| 2860 |
|
| 2861 |
‘IBM038’ |
| 2862 |
‘038’, ‘CP038’ and ‘EBCDIC-INT’ are aliases for this charset. |
| 2863 |
Source: IBM 3174 Character Set Ref, GA27-3831-02, March 1990. |
| 2864 |
|
| 2865 |
‘IBM1004’ |
| 2866 |
‘1004’, ‘CP1004’ and ‘os2latin1’ are aliases for this charset. |
| 2867 |
Source: CEN/TC304 N283, 1994-02-04. |
| 2868 |
|
| 2869 |
‘IBM1026’ |
| 2870 |
‘1026’ and ‘CP1026’ are aliases for this charset. Source: IBM NLS |
| 2871 |
RM Vol2 SE09-8002-01, March 1990. |
| 2872 |
|
| 2873 |
‘IBM1047’ |
| 2874 |
‘1047’ and ‘CP1047’ are aliases for this charset. Source: IBM |
| 2875 |
Character Data Representation Architecture. Registry SC09-1391-00 |
| 2876 |
p 150. |
| 2877 |
|
| 2878 |
‘IBM256’ |
| 2879 |
‘256’, ‘CP256’ and ‘EBCDIC-INT1’ are aliases for this charset. |
| 2880 |
Source: IBM Registry C-H 3-3220-050. |
| 2881 |
|
| 2882 |
‘IBM273’ |
| 2883 |
‘273’ and ‘CP273’ are aliases for this charset. Source: IBM NLS RM |
| 2884 |
Vol2 SE09-8002-01, March 1990. |
| 2885 |
|
| 2886 |
‘IBM274’ |
| 2887 |
‘274’, ‘CP274’ and ‘EBCDIC-BE’ are aliases for this charset. |
| 2888 |
Source: IBM 3174 Character Set Ref, GA27-3831-02, March 1990. |
| 2889 |
|
| 2890 |
‘IBM275’ |
| 2891 |
‘275’, ‘CP275’ and ‘EBCDIC-BR’ are aliases for this charset. |
| 2892 |
Source: IBM NLS RM Vol2 SE09-8002-01, March 1990. |
| 2893 |
|
| 2894 |
‘IBM277’ |
| 2895 |
‘EBCDIC-CP-DK’ and ‘EBCDIC-CP-NO’ are aliases for this charset. |
| 2896 |
Source: IBM NLS RM Vol2 SE09-8002-01, March 1990. |
| 2897 |
|
| 2898 |
‘IBM278’ |
| 2899 |
‘278’, ‘CP278’, ‘ebcdic-cp-fi’ and ‘ebcdic-cp-se’ are aliases for |
| 2900 |
this charset. Source: IBM NLS RM Vol2 SE09-8002-01, March 1990. |
| 2901 |
|
| 2902 |
‘IBM280’ |
| 2903 |
‘280’, ‘CP280’ and ‘ebcdic-cp-it’ are aliases for this charset. |
| 2904 |
Source: IBM NLS RM Vol2 SE09-8002-01, March 1990. |
| 2905 |
|
| 2906 |
‘IBM281’ |
| 2907 |
‘281’, ‘CP281’ and ‘EBCDIC-JP-E’ are aliases for this charset. |
| 2908 |
Source: IBM 3174 Character Set Ref, GA27-3831-02, March 1990. |
| 2909 |
|
| 2910 |
‘IBM284’ |
| 2911 |
‘284’, ‘CP284’ and ‘ebcdic-cp-es’ are aliases for this charset. |
| 2912 |
Source: IBM NLS RM Vol2 SE09-8002-01, March 1990. |
| 2913 |
|
| 2914 |
‘IBM285’ |
| 2915 |
‘285’, ‘CP285’ and ‘ebcdic-cp-gb’ are aliases for this charset. |
| 2916 |
Source: IBM NLS RM Vol2 SE09-8002-01, March 1990. |
| 2917 |
|
| 2918 |
‘IBM290’ |
| 2919 |
‘290’, ‘CP290’ and ‘EBCDIC-JP-kana’ are aliases for this charset. |
| 2920 |
Source: IBM 3174 Character Set Ref, GA27-3831-02, March 1990. |
| 2921 |
|
| 2922 |
‘IBM297’ |
| 2923 |
‘297’, ‘CP297’ and ‘ebcdic-cp-fr’ are aliases for this charset. |
| 2924 |
Source: IBM NLS RM Vol2 SE09-8002-01, March 1990. |
| 2925 |
|
| 2926 |
‘IBM420’ |
| 2927 |
‘420’, ‘CP420’ and ‘ebcdic-cp-ar1’ are aliases for this charset. |
| 2928 |
Source: IBM NLS RM Vol2 SE09-8002-01, March 1990. IBM NLS RM p |
| 2929 |
11-11. |
| 2930 |
|
| 2931 |
‘IBM423’ |
| 2932 |
‘423’, ‘CP423’ and ‘ebcdic-cp-gr’ are aliases for this charset. |
| 2933 |
Source: IBM NLS RM Vol2 SE09-8002-01, March 1990. |
| 2934 |
|
| 2935 |
‘IBM424’ |
| 2936 |
‘424’, ‘CP424’ and ‘ebcdic-cp-he’ are aliases for this charset. |
| 2937 |
Source: IBM NLS RM Vol2 SE09-8002-01, March 1990. |
| 2938 |
|
| 2939 |
‘IBM437’ |
| 2940 |
‘437’ and ‘CP437’ are aliases for this charset. Source: IBM NLS RM |
| 2941 |
Vol2 SE09-8002-01, March 1990. |
| 2942 |
|
| 2943 |
‘IBM500’ |
| 2944 |
‘500’, ‘500V1’, ‘CP500’, ‘ebcdic-cp-be’ and ‘ebcdic-cp-ch’ are |
| 2945 |
aliases for this charset. Source: IBM NLS RM Vol2 SE09-8002-01, |
| 2946 |
March 1990. |
| 2947 |
|
| 2948 |
‘IBM850’ |
| 2949 |
‘850’ and ‘CP850’ are aliases for this charset. Source: IBM NLS RM |
| 2950 |
Vol2 SE09-8002-01, March 1990. Source: UNICODE 1.0. |
| 2951 |
|
| 2952 |
‘IBM851’ |
| 2953 |
‘851’ and ‘CP851’ are aliases for this charset. Source: IBM NLS RM |
| 2954 |
Vol2 SE09-8002-01, March 1990. |
| 2955 |
|
| 2956 |
‘IBM852’ |
| 2957 |
‘852’, ‘CP852’, ‘pcl2’ and ‘pclatin2’ are aliases for this charset. |
| 2958 |
Source: IBM NLS RM Vol2 SE09-8002-01, March 1990. |
| 2959 |
|
| 2960 |
‘IBM855’ |
| 2961 |
‘855’ and ‘CP855’ are aliases for this charset. Source: IBM NLS RM |
| 2962 |
Vol2 SE09-8002-01, March 1990. |
| 2963 |
|
| 2964 |
‘IBM857’ |
| 2965 |
‘857’ and ‘CP857’ are aliases for this charset. Source: IBM NLS RM |
| 2966 |
Vol2 SE09-8002-01, March 1990. |
| 2967 |
|
| 2968 |
‘IBM860’ |
| 2969 |
‘860’ and ‘CP860’ are aliases for this charset. Source: IBM NLS RM |
| 2970 |
Vol2 SE09-8002-01, March 1990. |
| 2971 |
|
| 2972 |
‘IBM861’ |
| 2973 |
‘861’, ‘CP861’ and ‘cp-is’ are aliases for this charset. Source: |
| 2974 |
IBM NLS RM Vol2 SE09-8002-01, March 1990. |
| 2975 |
|
| 2976 |
‘IBM862’ |
| 2977 |
‘862’ and ‘CP862’ are aliases for this charset. Source: IBM NLS RM |
| 2978 |
Vol2 SE09-8002-01, March 1990. |
| 2979 |
|
| 2980 |
‘IBM863’ |
| 2981 |
‘863’ and ‘CP863’ are aliases for this charset. Source: IBM |
| 2982 |
Keyboard layouts and code pages, PN 07G4586 June 1991. |
| 2983 |
|
| 2984 |
‘IBM864’ |
| 2985 |
‘864’ and ‘CP864’ are aliases for this charset. Source: IBM |
| 2986 |
Keyboard layouts and code pages, PN 07G4586 June 1991. |
| 2987 |
|
| 2988 |
‘IBM865’ |
| 2989 |
‘865’ and ‘CP865’ are aliases for this charset. Source: IBM DOS |
| 2990 |
3.3 Ref (Abridged), 94X9575 (Feb 1987). |
| 2991 |
|
| 2992 |
‘IBM868’ |
| 2993 |
‘868’, ‘CP868’ and ‘cp-ar’ are aliases for this charset. Source: |
| 2994 |
IBM NLS RM Vol2 SE09-8002-01, March 1990. |
| 2995 |
|
| 2996 |
‘IBM869’ |
| 2997 |
‘869’, ‘CP869’ and ‘cp-gr’ are aliases for this charset. Source: |
| 2998 |
IBM Keyboard layouts and code pages, PN 07G4586 June 1991. |
| 2999 |
|
| 3000 |
‘IBM870’ |
| 3001 |
‘870’, ‘CP870’, ‘ebcdic-cp-roece’ and ‘ebcdic-cp-yu’ are aliases |
| 3002 |
for this charset. Source: IBM NLS RM Vol2 SE09-8002-01, March |
| 3003 |
1990. |
| 3004 |
|
| 3005 |
‘IBM871’ |
| 3006 |
‘871’, ‘CP871’ and ‘ebcdic-cp-is’ are aliases for this charset. |
| 3007 |
Source: IBM NLS RM Vol2 SE09-8002-01, March 1990. |
| 3008 |
|
| 3009 |
‘IBM875’ |
| 3010 |
‘875’, ‘CP875’ and ‘EBCDIC-Greek’ are aliases for this charset. |
| 3011 |
Source: UNICODE 1.0. |
| 3012 |
|
| 3013 |
‘IBM880’ |
| 3014 |
‘880’, ‘CP880’ and ‘EBCDIC-Cyrillic’ are aliases for this charset. |
| 3015 |
Source: IBM NLS RM Vol2 SE09-8002-01, March 1990. |
| 3016 |
|
| 3017 |
‘IBM891’ |
| 3018 |
‘891’ and ‘CP891’ are aliases for this charset. Source: IBM NLS RM |
| 3019 |
Vol2 SE09-8002-01, March 1990. |
| 3020 |
|
| 3021 |
‘IBM903’ |
| 3022 |
‘903’ and ‘CP903’ are aliases for this charset. Source: IBM NLS RM |
| 3023 |
Vol2 SE09-8002-01, March 1990. |
| 3024 |
|
| 3025 |
‘IBM904’ |
| 3026 |
‘904’ and ‘CP904’ are aliases for this charset. Source: IBM NLS RM |
| 3027 |
Vol2 SE09-8002-01, March 1990. |
| 3028 |
|
| 3029 |
‘IBM905’ |
| 3030 |
‘905’, ‘CP905’ and ‘ebcdic-cp-tr’ are aliases for this charset. |
| 3031 |
Source: IBM 3174 Character Set Ref, GA27-3831-02, March 1990. |
| 3032 |
|
| 3033 |
‘IBM918’ |
| 3034 |
‘918’, ‘CP918’ and ‘ebcdic-cp-ar2’ are aliases for this charset. |
| 3035 |
Source: IBM NLS RM Vol2 SE09-8002-01, March 1990. |
| 3036 |
|
| 3037 |
‘IEC_P27-1’ |
| 3038 |
‘iso-ir-143’ is an alias for this charset. Source: ISO 2375 |
| 3039 |
registry. |
| 3040 |
|
| 3041 |
‘INIS’ |
| 3042 |
‘iso-ir-49’ is an alias for this charset. Source: ISO 2375 |
| 3043 |
registry. |
| 3044 |
|
| 3045 |
‘INIS-8’ |
| 3046 |
‘iso-ir-50’ is an alias for this charset. Source: ISO 2375 |
| 3047 |
registry. |
| 3048 |
|
| 3049 |
‘INIS-cyrillic’ |
| 3050 |
‘iso-ir-51’ is an alias for this charset. Source: ISO 2375 |
| 3051 |
registry. |
| 3052 |
|
| 3053 |
‘INVARIANT’ |
| 3054 |
‘iso-ir-170’ is an alias for this charset. |
| 3055 |
|
| 3056 |
‘ISO-8859-1’ |
| 3057 |
‘819’, ‘CP819’, ‘IBM819’, ‘ISO8859-1’, ‘ISO_8859-1’, |
| 3058 |
‘ISO_8859-1:1987’, ‘iso-ir-100’, ‘l1’ and ‘latin1’ are aliases for |
| 3059 |
this charset. Source: ISO 2375 registry. |
| 3060 |
|
| 3061 |
‘ISO-8859-10’ |
| 3062 |
‘ISO8859-10’, ‘ISO_8859-10’, ‘ISO_8859-10:1993’, ‘L6’, ‘iso-ir-157’ |
| 3063 |
and ‘latin6’ are aliases for this charset. Source: ISO 2375 |
| 3064 |
registry. |
| 3065 |
|
| 3066 |
‘ISO-8859-13’ |
| 3067 |
‘ISO8859-13’, ‘ISO_8859-13’, ‘ISO_8859-13:1998’, ‘iso-baltic’, |
| 3068 |
‘iso-ir-179a’, ‘l7’ and ‘latin7’ are aliases for this charset. |
| 3069 |
Source: ISO 2375 registry. |
| 3070 |
|
| 3071 |
‘ISO-8859-14’ |
| 3072 |
‘ISO8859-14’, ‘ISO_8859-14’, ‘ISO_8859-14:1998’, ‘iso-celtic’, |
| 3073 |
‘iso-ir-199’, ‘l8’ and ‘latin8’ are aliases for this charset. |
| 3074 |
Source: ISO 2375 registry. |
| 3075 |
|
| 3076 |
‘ISO-8859-15’ |
| 3077 |
‘ISO8859-15’, ‘ISO_8859-15’, ‘ISO_8859-15:1998’, ‘iso-ir-203’, ‘l9’ |
| 3078 |
and ‘latin9’ are aliases for this charset. Source: ISO 2375 |
| 3079 |
registry. |
| 3080 |
|
| 3081 |
‘ISO-8859-2’ |
| 3082 |
‘912’, ‘CP912’, ‘IBM912’, ‘ISO8859-2’, ‘ISO_8859-2’, |
| 3083 |
‘ISO_8859-2:1987’, ‘iso-ir-101’, ‘l2’ and ‘latin2’ are aliases for |
| 3084 |
this charset. Source: ISO 2375 registry. |
| 3085 |
|
| 3086 |
‘ISO-8859-3’ |
| 3087 |
‘ISO8859-3’, ‘ISO_8859-3’, ‘ISO_8859-3:1988’, ‘iso-ir-109’, ‘l3’ |
| 3088 |
and ‘latin3’ are aliases for this charset. Source: ISO 2375 |
| 3089 |
registry. |
| 3090 |
|
| 3091 |
‘ISO-8859-4’ |
| 3092 |
‘ISO8859-4’, ‘ISO_8859-4’, ‘ISO_8859-4:1988’, ‘iso-ir-110’, ‘l4’ |
| 3093 |
and ‘latin4’ are aliases for this charset. Source: ISO 2375 |
| 3094 |
registry. |
| 3095 |
|
| 3096 |
‘ISO-8859-5’ |
| 3097 |
‘ISO8859-5’, ‘ISO_8859-5’, ‘ISO_8859-5:1988’, ‘cyrillic’ and |
| 3098 |
‘iso-ir-144’ are aliases for this charset. Source: ISO 2375 |
| 3099 |
registry. |
| 3100 |
|
| 3101 |
‘ISO-8859-6’ |
| 3102 |
‘ASMO-708’, ‘ECMA-114’, ‘ISO8859-6’, ‘ISO_8859-6’, |
| 3103 |
‘ISO_8859-6:1987’, ‘arabic’ and ‘iso-ir-127’ are aliases for this |
| 3104 |
charset. Source: ISO 2375 registry. |
| 3105 |
|
| 3106 |
‘ISO-8859-7’ |
| 3107 |
‘ECMA-118’, ‘ELOT_928’, ‘ISO8859-7’, ‘ISO_8859-7’, |
| 3108 |
‘ISO_8859-7:1987’, ‘greek’, ‘greek8’ and ‘iso-ir-126’ are aliases |
| 3109 |
for this charset. Source: ISO 2375 registry. |
| 3110 |
|
| 3111 |
‘ISO-8859-8’ |
| 3112 |
‘ISO8859-8’, ‘ISO_8859-8’, ‘ISO_8859-8:1988’, ‘hebrew’ and |
| 3113 |
‘iso-ir-138’ are aliases for this charset. Source: ISO 2375 |
| 3114 |
registry. |
| 3115 |
|
| 3116 |
‘ISO-8859-9’ |
| 3117 |
‘ISO8859-9’, ‘ISO_8859-9’, ‘ISO_8859-9:1989’, ‘iso-ir-148’, ‘l5’ |
| 3118 |
and ‘latin5’ are aliases for this charset. Source: ISO 2375 |
| 3119 |
registry. |
| 3120 |
|
| 3121 |
‘ISO_10367-box’ |
| 3122 |
‘iso-ir-155’ is an alias for this charset. Source: ISO 2375 |
| 3123 |
registry. |
| 3124 |
|
| 3125 |
‘ISO_2033-1983’ |
| 3126 |
‘e13b’ and ‘iso-ir-98’ are aliases for this charset. Source: ISO |
| 3127 |
2375 registry. |
| 3128 |
|
| 3129 |
‘ISO_5427’ |
| 3130 |
‘iso-ir-37’ is an alias for this charset. Source: ISO 2375 |
| 3131 |
registry. |
| 3132 |
|
| 3133 |
‘ISO_5427-ext’ |
| 3134 |
‘ISO_5427:1981’ and ‘iso-ir-54’ are aliases for this charset. |
| 3135 |
Source: ISO 2375 registry. |
| 3136 |
|
| 3137 |
‘ISO_5428’ |
| 3138 |
‘ISO_5428:1980’ and ‘iso-ir-55’ are aliases for this charset. |
| 3139 |
Source: ISO 2375 registry. |
| 3140 |
|
| 3141 |
‘ISO_646.basic’ |
| 3142 |
‘ISO_646.basic:1983’ and ‘ref’ are aliases for this charset. |
| 3143 |
Source: ISO 2375 registry. |
| 3144 |
|
| 3145 |
‘ISO_646.irv’ |
| 3146 |
‘ISO_646.irv:1983’, ‘irv’ and ‘iso-ir-2’ are aliases for this |
| 3147 |
charset. Source: ISO 2375 registry. |
| 3148 |
|
| 3149 |
‘ISO_6937-2-25’ |
| 3150 |
‘iso-ir-152’ is an alias for this charset. Source: ISO 2375 |
| 3151 |
registry. |
| 3152 |
|
| 3153 |
‘ISO_8859-supp’ |
| 3154 |
‘iso-ir-154’ and ‘latin1-2-5’ are aliases for this charset. |
| 3155 |
Source: ISO 2375 registry. |
| 3156 |
|
| 3157 |
‘IT’ |
| 3158 |
‘ISO646-IT’ and ‘iso-ir-15’ are aliases for this charset. Source: |
| 3159 |
ISO 2375 registry. |
| 3160 |
|
| 3161 |
‘JIS_C6220-1969-jp’ |
| 3162 |
‘JIS_C6220-1969’, ‘iso-ir-13’, ‘katakana’ and ‘x0201-7’ are aliases |
| 3163 |
for this charset. Source: ISO 2375 registry. |
| 3164 |
|
| 3165 |
‘JIS_C6220-1969-ro’ |
| 3166 |
‘ISO646-JP’, ‘iso-ir-14’ and ‘jp’ are aliases for this charset. |
| 3167 |
Source: ISO 2375 registry. |
| 3168 |
|
| 3169 |
‘JIS_C6229-1984-a’ |
| 3170 |
‘jp-ocr-a’ is an alias for this charset. Source: ISO 2375 |
| 3171 |
registry. |
| 3172 |
|
| 3173 |
‘JIS_C6229-1984-b’ |
| 3174 |
‘ISO646-JP-OCR-B’ and ‘jp-ocr-b’ are aliases for this charset. |
| 3175 |
Source: ISO 2375 registry. |
| 3176 |
|
| 3177 |
‘JIS_C6229-1984-b-add’ |
| 3178 |
‘iso-ir-93’ and ‘jp-ocr-b-add’ are aliases for this charset. |
| 3179 |
Source: ISO 2375 registry. |
| 3180 |
|
| 3181 |
‘JIS_C6229-1984-hand’ |
| 3182 |
‘iso-ir-94’ and ‘jp-ocr-hand’ are aliases for this charset. |
| 3183 |
Source: ISO 2375 registry. |
| 3184 |
|
| 3185 |
‘JIS_C6229-1984-hand-add’ |
| 3186 |
‘iso-ir-95’ and ‘jp-ocr-hand-add’ are aliases for this charset. |
| 3187 |
Source: ISO 2375 registry. |
| 3188 |
|
| 3189 |
‘JIS_C6229-1984-kana’ |
| 3190 |
‘iso-ir-96’ is an alias for this charset. Source: ISO 2375 |
| 3191 |
registry. |
| 3192 |
|
| 3193 |
‘JIS_X0201’ |
| 3194 |
‘X0201’ is an alias for this charset. |
| 3195 |
|
| 3196 |
‘JUS_I.B1.002’ |
| 3197 |
‘ISO646-YU’, ‘iso-ir-141’, ‘js’ and ‘yu’ are aliases for this |
| 3198 |
charset. Source: ISO 2375 registry. |
| 3199 |
|
| 3200 |
‘JUS_I.B1.003-mac’ |
| 3201 |
‘iso-ir-147’ and ‘macedonian’ are aliases for this charset. |
| 3202 |
Source: ISO 2375 registry. |
| 3203 |
|
| 3204 |
‘JUS_I.B1.003-serb’ |
| 3205 |
‘iso-ir-146’ and ‘serbian’ are aliases for this charset. Source: |
| 3206 |
ISO 2375 registry. |
| 3207 |
|
| 3208 |
‘KOI-7’ |
| 3209 |
Source: Andrey A. Chernov <[email protected]>. |
| 3210 |
|
| 3211 |
‘KOI-8’ |
| 3212 |
‘GOST_19768-74’ is an alias for this charset. Source: Andrey A. |
| 3213 |
Chernov <[email protected]>. |
| 3214 |
|
| 3215 |
‘KOI8-R’ |
| 3216 |
Source: RFC1489 via Gabor Kiss <[email protected]>. And Andrey A. |
| 3217 |
Chernov <[email protected]>. |
| 3218 |
|
| 3219 |
‘KOI8-RU’ |
| 3220 |
Source: http://cad.ntu-kpi.kiev.ua/multiling/koi8-ru/. |
| 3221 |
|
| 3222 |
‘KOI8-U’ |
| 3223 |
Source: RFC 2319. Mibenum: 2088. Source: |
| 3224 |
http://www.net.ua/KOI8-U/. |
| 3225 |
|
| 3226 |
‘KSC5636’ |
| 3227 |
‘ISO646-KR’ is an alias for this charset. |
| 3228 |
|
| 3229 |
‘Latin-greek-1’ |
| 3230 |
‘iso-ir-27’ is an alias for this charset. Source: ISO 2375 |
| 3231 |
registry. |
| 3232 |
|
| 3233 |
‘MSZ_7795.3’ |
| 3234 |
‘ISO646-HU’, ‘hu’ and ‘iso-ir-86’ are aliases for this charset. |
| 3235 |
Source: ISO 2375 registry. |
| 3236 |
|
| 3237 |
‘NATS-DANO’ |
| 3238 |
‘iso-ir-9-1’ is an alias for this charset. Source: ISO 2375 |
| 3239 |
registry. |
| 3240 |
|
| 3241 |
‘NATS-DANO-ADD’ |
| 3242 |
‘iso-ir-9-2’ is an alias for this charset. Source: ISO 2375 |
| 3243 |
registry. |
| 3244 |
|
| 3245 |
‘NATS-SEFI’ |
| 3246 |
‘iso-ir-8-1’ is an alias for this charset. Source: ISO 2375 |
| 3247 |
registry. |
| 3248 |
|
| 3249 |
‘NATS-SEFI-ADD’ |
| 3250 |
‘iso-ir-8-2’ is an alias for this charset. Source: ISO 2375 |
| 3251 |
registry. |
| 3252 |
|
| 3253 |
‘NC_NC00-10’ |
| 3254 |
‘ISO646-CU’, ‘NC_NC00-10:81’, ‘cuba’ and ‘iso-ir-151’ are aliases |
| 3255 |
for this charset. Source: ISO 2375 registry. |
| 3256 |
|
| 3257 |
‘NF_Z_62-010’ |
| 3258 |
‘ISO646-FR’, ‘fr’ and ‘iso-ir-69’ are aliases for this charset. |
| 3259 |
Source: ISO 2375 registry. |
| 3260 |
|
| 3261 |
‘NF_Z_62-010_(1973)’ |
| 3262 |
‘ISO646-FR1’ and ‘iso-ir-25’ are aliases for this charset. Source: |
| 3263 |
ISO 2375 registry. |
| 3264 |
|
| 3265 |
‘NS_4551-1’ |
| 3266 |
‘ISO646-NO’, ‘iso-ir-60’ and ‘no’ are aliases for this charset. |
| 3267 |
Source: ISO 2375 registry. |
| 3268 |
|
| 3269 |
‘NS_4551-2’ |
| 3270 |
‘ISO646-NO2’, ‘iso-ir-61’ and ‘no2’ are aliases for this charset. |
| 3271 |
Source: ISO 2375 registry. |
| 3272 |
|
| 3273 |
‘NeXTSTEP’ |
| 3274 |
‘next’ is an alias for this charset. Source: Peter Svanberg - |
| 3275 |
[email protected]. |
| 3276 |
|
| 3277 |
‘PT’ |
| 3278 |
‘ISO646-PT’ and ‘iso-ir-16’ are aliases for this charset. Source: |
| 3279 |
ISO 2375 registry. |
| 3280 |
|
| 3281 |
‘PT2’ |
| 3282 |
‘ISO646-PT2’ and ‘iso-ir-84’ are aliases for this charset. Source: |
| 3283 |
ISO 2375 registry. |
| 3284 |
|
| 3285 |
‘SEN_850200_B’ |
| 3286 |
‘FI’, ‘ISO646-FI’, ‘ISO646-SE’, ‘SS636127’, ‘iso-ir-10’ and ‘se’ |
| 3287 |
are aliases for this charset. Source: ISO 2375 registry. |
| 3288 |
|
| 3289 |
‘SEN_850200_C’ |
| 3290 |
‘ISO646-SE2’, ‘iso-ir-11’ and ‘se2’ are aliases for this charset. |
| 3291 |
Source: ISO 2375 registry. |
| 3292 |
|
| 3293 |
‘T.61-7bit’ |
| 3294 |
‘iso-ir-102’ is an alias for this charset. Source: ISO 2375 |
| 3295 |
registry. |
| 3296 |
|
| 3297 |
‘baltic’ |
| 3298 |
‘iso-ir-179’ is an alias for this charset. Source: ISO 2375 |
| 3299 |
registry. &g1esc x2d56 &g2esc x2e56 &g3esc x2f56. |
| 3300 |
|
| 3301 |
‘greek-ccitt’ |
| 3302 |
‘iso-ir-150’ is an alias for this charset. Source: ISO 2375 |
| 3303 |
registry. |
| 3304 |
|
| 3305 |
‘greek7’ |
| 3306 |
‘iso-ir-88’ is an alias for this charset. Source: ISO 2375 |
| 3307 |
registry. |
| 3308 |
|
| 3309 |
‘greek7-old’ |
| 3310 |
‘iso-ir-18’ is an alias for this charset. Source: ISO 2375 |
| 3311 |
registry. |
| 3312 |
|
| 3313 |
‘hp-roman8’ |
| 3314 |
‘r8’ and ‘roman8’ are aliases for this charset. Source: LaserJet |
| 3315 |
IIP Printer User's Manual,. HP part no 33471-90901, |
| 3316 |
Hewlet-Packard, June 1989. |
| 3317 |
|
| 3318 |
‘latin-greek’ |
| 3319 |
‘iso-ir-19’ is an alias for this charset. Source: ISO 2375 |
| 3320 |
registry. |
| 3321 |
|
| 3322 |
‘mac-is’ |
| 3323 |
|
| 3324 |
‘macintosh’ |
| 3325 |
‘mac’ is an alias for this charset. Source: The Unicode Standard |
| 3326 |
ver 1.0, ISBN 0-201-56788-1, Oct 1991. |
| 3327 |
|
| 3328 |
‘macintosh_ce’ |
| 3329 |
‘macce’ is an alias for this charset. Source: Macintosh CE fonts. |
| 3330 |
|
| 3331 |
‘sami’ |
| 3332 |
‘iso-ir-158’, ‘lap’ and ‘latin-lap’ are aliases for this charset. |
| 3333 |
Source: ISO 2375 registry. |
| 3334 |
|
| 3335 |
|
| 3336 |
File: recode.info, Node: ASCII misc, Next: IBM and MS, Prev: Tabular, Up: Top |
| 3337 |
|
| 3338 |
8 ASCII and some derivatives |
| 3339 |
**************************** |
| 3340 |
|
| 3341 |
* Menu: |
| 3342 |
|
| 3343 |
* ASCII:: Usual ASCII |
| 3344 |
* ISO 8859:: ASCII extended by Latin Alphabets |
| 3345 |
* ASCII-BS:: ASCII 7-bits, ‘BS’ to overstrike |
| 3346 |
* flat:: ASCII without diacritics nor underline |
| 3347 |
|
| 3348 |
|
| 3349 |
File: recode.info, Node: ASCII, Next: ISO 8859, Prev: ASCII misc, Up: ASCII misc |
| 3350 |
|
| 3351 |
8.1 Usual ASCII |
| 3352 |
=============== |
| 3353 |
|
| 3354 |
This charset is available in Recode under the name ‘ASCII’. In fact, |
| 3355 |
its true name is ‘ANSI_X3.4-1968’ as per RFC 1345, accepted aliases |
| 3356 |
being ‘ANSI_X3.4-1986’, ‘ASCII’, ‘IBM367’, ‘ISO646-US’, |
| 3357 |
‘ISO_646.irv:1991’, ‘US-ASCII’, ‘cp367’, ‘iso-ir-6’ and ‘us’. The |
| 3358 |
shortest way of specifying it in Recode is ‘us’. |
| 3359 |
|
| 3360 |
This documentation used to include ASCII tables. They have been |
| 3361 |
removed since the ‘recode’ program can now recreate these easily: |
| 3362 |
|
| 3363 |
recode -lf us for commented ASCII |
| 3364 |
recode -ld us for concise decimal table |
| 3365 |
recode -lo us for concise octal table |
| 3366 |
recode -lh us for concise hexadecimal table |
| 3367 |
|
| 3368 |
|
| 3369 |
File: recode.info, Node: ISO 8859, Next: ASCII-BS, Prev: ASCII, Up: ASCII misc |
| 3370 |
|
| 3371 |
8.2 ASCII extended by Latin Alphabets |
| 3372 |
===================================== |
| 3373 |
|
| 3374 |
There are many Latin charsets. The following has been written by Tim |
| 3375 |
Lasko <[email protected]>, a long while ago: |
| 3376 |
|
| 3377 |
ISO Latin-1, or more completely ISO Latin Alphabet No 1, is now an |
| 3378 |
international standard as of February 1987 (IS 8859, Part 1). For |
| 3379 |
those American USEnet'rs that care, the 8-bit ASCII standard, which |
| 3380 |
is essentially the same code, is going through the final |
| 3381 |
administrative processes prior to publication. ISO Latin-1 (IS |
| 3382 |
8859/1) is actually one of an entire family of eight-bit one-byte |
| 3383 |
character sets, all having ASCII on the left hand side, and with |
| 3384 |
varying repertoires on the right hand side: |
| 3385 |
|
| 3386 |
• Latin Alphabet No 1 (caters to Western Europe - now approved). |
| 3387 |
• Latin Alphabet No 2 (caters to Eastern Europe - now approved). |
| 3388 |
• Latin Alphabet No 3 (caters to SE Europe + others - in draft |
| 3389 |
ballot). |
| 3390 |
• Latin Alphabet No 4 (caters to Northern Europe - in draft |
| 3391 |
ballot). |
| 3392 |
• Latin-Cyrillic alphabet (right half all Cyrillic - processing |
| 3393 |
currently suspended pending USSR input). |
| 3394 |
• Latin-Arabic alphabet (right half all Arabic - now approved). |
| 3395 |
• Latin-Greek alphabet (right half Greek + symbols - in draft |
| 3396 |
ballot). |
| 3397 |
• Latin-Hebrew alphabet (right half Hebrew + symbols - |
| 3398 |
proposed). |
| 3399 |
|
| 3400 |
The ISO Latin Alphabet 1 is available as a charset in Recode under |
| 3401 |
the name ‘Latin-1’. In fact, its true name is ‘ISO_8859-1:1987’ as per |
| 3402 |
RFC 1345, accepted aliases being ‘CP819’, ‘IBM819’, ‘ISO-8859-1’, |
| 3403 |
‘ISO_8859-1’, ‘iso-ir-100’, ‘l1’ and ‘Latin-1’. The shortest way of |
| 3404 |
specifying it in Recode is ‘l1’. |
| 3405 |
|
| 3406 |
It is an eight-bit code which coincides with ASCII for the lower |
| 3407 |
half. This documentation used to include Latin-1 tables. They have |
| 3408 |
been removed since the ‘recode’ program can now recreate these easily: |
| 3409 |
|
| 3410 |
recode -lf l1 for commented ISO Latin-1 |
| 3411 |
recode -ld l1 for concise decimal table |
| 3412 |
recode -lo l1 for concise octal table |
| 3413 |
recode -lh l1 for concise hexadecimal table |
| 3414 |
|
| 3415 |
|
| 3416 |
File: recode.info, Node: ASCII-BS, Next: flat, Prev: ISO 8859, Up: ASCII misc |
| 3417 |
|
| 3418 |
8.3 ASCII 7-bits, ‘BS’ to overstrike |
| 3419 |
==================================== |
| 3420 |
|
| 3421 |
This charset is available in Recode under the name ‘ASCII-BS’, with ‘BS’ |
| 3422 |
as an acceptable alias. |
| 3423 |
|
| 3424 |
The file is straight ASCII, seven bits only. According to the |
| 3425 |
definition of ASCII, diacritics are applied by a sequence of three |
| 3426 |
characters: the letter, one ‘BS’, the diacritic mark. We deviate |
| 3427 |
slightly from this by exchanging the diacritic mark and the letter so, |
| 3428 |
on a screen device, the diacritic will disappear and let the letter |
| 3429 |
alone. At recognition time, both methods are acceptable. |
| 3430 |
|
| 3431 |
The French quotes are coded by the sequences: ‘< BS "’ or ‘" BS <’ |
| 3432 |
for the opening quote and ‘> BS "’ or ‘" BS >’ for the closing quote. |
| 3433 |
This artificial convention was inherited in straight ‘ASCII-BS’ from |
| 3434 |
habits around ‘Bang-Bang’ entry, and is not well known. But we decided |
| 3435 |
to stick to it so that ‘ASCII-BS’ charset will not lose French quotes. |
| 3436 |
|
| 3437 |
The ‘ASCII-BS’ charset is independent of ‘ASCII’, and different. The |
| 3438 |
following examples demonstrate this, knowing at advance that ‘!2’ is the |
| 3439 |
‘Bang-Bang’ way of representing an ‘e’ with an acute accent. Compare: |
| 3440 |
|
| 3441 |
% echo \!2 | recode -v bang..l1/d |
| 3442 |
Request: Bang-Bang..ISO-8859-1/Decimal-1 |
| 3443 |
233, 10 |
| 3444 |
|
| 3445 |
with: |
| 3446 |
|
| 3447 |
% echo \!2 | recode -v bang..bs/d |
| 3448 |
Request: Bang-Bang..ISO-8859-1..ASCII-BS/Decimal-1 |
| 3449 |
39, 8, 101, 10 |
| 3450 |
|
| 3451 |
In the first case, the ‘e’ with an acute accent is merely transmitted |
| 3452 |
by the ‘Latin-1..ASCII’ mapping, not having a special recoding rule for |
| 3453 |
it. In the ‘Latin-1..ASCII-BS’ case, the acute accent is applied over |
| 3454 |
the ‘e’ with a backspace: diacriticised characters have special rules. |
| 3455 |
For the ‘ASCII-BS’ charset, reversibility is still possible, but there |
| 3456 |
might be difficult cases. |
| 3457 |
|
| 3458 |
|
| 3459 |
File: recode.info, Node: flat, Prev: ASCII-BS, Up: ASCII misc |
| 3460 |
|
| 3461 |
8.4 ASCII without diacritics nor underline |
| 3462 |
========================================== |
| 3463 |
|
| 3464 |
This charset is available in Recode under the name ‘flat’. |
| 3465 |
|
| 3466 |
This code is ASCII expunged of all diacritics and underlines, as long |
| 3467 |
as they are applied using three character sequences, with ‘BS’ in the |
| 3468 |
middle. Also, despite slightly unrelated, each control character is |
| 3469 |
represented by a sequence of two or three graphic characters. The |
| 3470 |
newline character, however, keeps its functionality and is not |
| 3471 |
represented. |
| 3472 |
|
| 3473 |
Note that charset ‘flat’ is a terminal charset. We can convert _to_ |
| 3474 |
‘flat’, but not _from_ it. |
| 3475 |
|
| 3476 |
|
| 3477 |
File: recode.info, Node: IBM and MS, Next: CDC, Prev: ASCII misc, Up: Top |
| 3478 |
|
| 3479 |
9 Some IBM or Microsoft charsets |
| 3480 |
******************************** |
| 3481 |
|
| 3482 |
Recode provides various IBM or Microsoft code pages (*note Tabular::). |
| 3483 |
An easy way to find them all at once out of Recode itself is through the |
| 3484 |
command: |
| 3485 |
|
| 3486 |
recode -l | egrep -i '(CP|IBM)[0-9]' |
| 3487 |
|
| 3488 |
But also, see few special charsets presented in the incoming sections. |
| 3489 |
|
| 3490 |
* Menu: |
| 3491 |
|
| 3492 |
* EBCDIC:: EBCDIC codes |
| 3493 |
* IBM-PC:: IBM's PC code |
| 3494 |
* Icon-QNX:: Unisys' Icon code |
| 3495 |
|
| 3496 |
|
| 3497 |
File: recode.info, Node: EBCDIC, Next: IBM-PC, Prev: IBM and MS, Up: IBM and MS |
| 3498 |
|
| 3499 |
9.1 EBCDIC code |
| 3500 |
=============== |
| 3501 |
|
| 3502 |
This charset is the IBM's External Binary Coded Decimal for Interchange |
| 3503 |
Coding. This is an eight bits code. The following three variants were |
| 3504 |
implemented in Recode independently of RFC 1345: |
| 3505 |
|
| 3506 |
‘EBCDIC’ |
| 3507 |
In Recode, the ‘us..ebcdic’ conversion is identical to ‘dd |
| 3508 |
conv=ebcdic’ conversion, and Recode ‘ebcdic..us’ conversion is |
| 3509 |
identical to ‘dd conv=ascii’ conversion. This charset also |
| 3510 |
represents the way Control Data Corporation relates EBCDIC to |
| 3511 |
8-bits ASCII. |
| 3512 |
|
| 3513 |
‘EBCDIC-CCC’ |
| 3514 |
In Recode, the ‘us..ebcdic-ccc’ or ‘ebcdic-ccc..us’ conversions |
| 3515 |
represent the way Concurrent Computer Corporation (formerly Perkin |
| 3516 |
Elmer) relates EBCDIC to 8-bits ASCII. |
| 3517 |
|
| 3518 |
‘EBCDIC-IBM’ |
| 3519 |
In Recode, the ‘us..ebcdic-ibm’ conversion is _almost_ identical to |
| 3520 |
the GNU ‘dd conv=ibm’ conversion. Given the exact ‘dd conv=ibm’ |
| 3521 |
conversion table, Recode once said: |
| 3522 |
|
| 3523 |
Codes 91 and 213 both recode to 173 |
| 3524 |
Codes 93 and 229 both recode to 189 |
| 3525 |
No character recodes to 74 |
| 3526 |
No character recodes to 106 |
| 3527 |
|
| 3528 |
So I arbitrarily chose to recode 213 by 74 and 229 by 106. This |
| 3529 |
makes the ‘EBCDIC-IBM’ recoding reversible, but this is not |
| 3530 |
necessarily the best correction. In any case, I think that GNU |
| 3531 |
‘dd’ should be amended. ‘dd’ and Recode should ideally agree on |
| 3532 |
the same correction. So, this table might change once again. |
| 3533 |
|
| 3534 |
RFC 1345 brings into Recode 15 other EBCDIC charsets, and 21 other |
| 3535 |
charsets having EBCDIC in at least one of their alias names. You can |
| 3536 |
get a list of all these by executing: |
| 3537 |
|
| 3538 |
recode -l | grep -i ebcdic |
| 3539 |
|
| 3540 |
Note that Recode may convert a pure stream of EBCDIC characters, but |
| 3541 |
it does not know how to handle binary data between records which is |
| 3542 |
sometimes used to delimit them and build physical blocks. If end of |
| 3543 |
lines are not marked, fixed record size may produce something readable, |
| 3544 |
but ‘VB’ or ‘VBS’ blocking is likely to yield some garbage in the |
| 3545 |
converted results. |
| 3546 |
|
| 3547 |
|
| 3548 |
File: recode.info, Node: IBM-PC, Next: Icon-QNX, Prev: EBCDIC, Up: IBM and MS |
| 3549 |
|
| 3550 |
9.2 IBM's PC code |
| 3551 |
================= |
| 3552 |
|
| 3553 |
This charset is available in Recode under the name ‘IBM-PC’, with ‘dos’, |
| 3554 |
‘MSDOS’ and ‘pc’ as acceptable aliases. The shortest way of specifying |
| 3555 |
it in Recode is ‘pc’. |
| 3556 |
|
| 3557 |
The charset is aimed towards a PC microcomputer from IBM or any |
| 3558 |
compatible. This is an eight-bit code. This charset is fairly old in |
| 3559 |
Recode, its tables were produced a long while ago by mere inspection of |
| 3560 |
a printed chart of the IBM-PC codes and glyph. |
| 3561 |
|
| 3562 |
It has ‘CR-LF’ as its implied surface. This means that, if the |
| 3563 |
original end of lines have to be preserved while going out of ‘IBM-PC’, |
| 3564 |
they should currently be added back through the usage of a surface on |
| 3565 |
the other charset, or better, just never removed. Here are examples for |
| 3566 |
both cases: |
| 3567 |
|
| 3568 |
recode pc..l2/cl < INPUT > OUTPUT |
| 3569 |
recode pc/..l2 < INPUT > OUTPUT |
| 3570 |
|
| 3571 |
RFC 1345 brings into Recode 44 ‘IBM’ charsets or code pages, and also |
| 3572 |
8 other code pages. You can get a list of these all these by |
| 3573 |
executing:(1) |
| 3574 |
|
| 3575 |
recode -l | egrep -i '(CP|IBM)[0-9]' |
| 3576 |
|
| 3577 |
All charset or aliases beginning with letters ‘CP’ or ‘IBM’ also have |
| 3578 |
‘CR-LF’ as their implied surface. The same is true for a purely numeric |
| 3579 |
alias in the same family. For example, all of ‘819’, ‘CP819’ and |
| 3580 |
‘IBM819’ imply ‘CR-LF’ as a surface. Note that ‘ISO-8859-1’ does _not_ |
| 3581 |
imply a surface, despite it shares the same tabular data as ‘819’. |
| 3582 |
|
| 3583 |
There are a few discrepancies between this ‘IBM-PC’ charset and the |
| 3584 |
very similar RFC 1345 charset ‘ibm437’. The ‘IBM-PC’ charset has two |
| 3585 |
extra characters at positions 20 (Latin-1 ‘0xB6’, Pilcrow) and 21 |
| 3586 |
(Latin-1 ‘0xA7’, Section sign); further, it has position 250 as ‘0xB7’, |
| 3587 |
middle dot, while ‘ibm437’ has middle dot at position 249. According to |
| 3588 |
this comparison of code tables: |
| 3589 |
<https://www.haible.de/bruno/charsets/conversion-tables/CP437.html> the |
| 3590 |
source for RFC 1345, ‘dkuug.dk/IBM437.TXT’ is the only source that thus |
| 3591 |
defines this mapping. |
| 3592 |
|
| 3593 |
---------- Footnotes ---------- |
| 3594 |
|
| 3595 |
(1) On DOS/Windows, stock shells do not know that apostrophes quote |
| 3596 |
special characters like ‘|’, so one needs to use double quotes instead |
| 3597 |
of apostrophes. |
| 3598 |
|
| 3599 |
|
| 3600 |
File: recode.info, Node: Icon-QNX, Prev: IBM-PC, Up: IBM and MS |
| 3601 |
|
| 3602 |
9.3 Unisys' Icon code |
| 3603 |
===================== |
| 3604 |
|
| 3605 |
This charset is available in Recode under the name ‘Icon-QNX’, with |
| 3606 |
‘QNX’ as an acceptable alias. |
| 3607 |
|
| 3608 |
The file is using Unisys' Icon way to represent diacritics with code |
| 3609 |
25 escape sequences, under the system QNX. This is a seven-bit code, |
| 3610 |
even if eight-bit codes can flow through as part of IBM-PC charset. |
| 3611 |
|
| 3612 |
|
| 3613 |
File: recode.info, Node: CDC, Next: Micros, Prev: IBM and MS, Up: Top |
| 3614 |
|
| 3615 |
10 Charsets for CDC machines |
| 3616 |
**************************** |
| 3617 |
|
| 3618 |
What is now Recode evolved out, through many transformations really, |
| 3619 |
from a set of programs which were originally written in “COMPASS”, |
| 3620 |
Control Data Corporation's assembler, with bits in FORTRAN, and later |
| 3621 |
rewritten in CDC 6000 Pascal. The CDC heritage shows by the fact some |
| 3622 |
old CDC charsets are still supported. |
| 3623 |
|
| 3624 |
The Recode author used to be familiar with CDC Scope-NOS/BE and |
| 3625 |
Kronos-NOS, and many CDC formats. Reading CDC tapes directly on other |
| 3626 |
machines is often a challenge, and Recode does not always solve it. It |
| 3627 |
helps having tapes created in coded mode instead of binary mode, and |
| 3628 |
using ‘S’ (Stranger) tapes instead of ‘I’ (Internal) tapes. ANSI labels |
| 3629 |
and multi-file tapes might be the source of trouble. There are ways to |
| 3630 |
handle a few Cyber Record Manager formats, but some of them might be |
| 3631 |
quite difficult to decode properly after the transfer is done. |
| 3632 |
|
| 3633 |
Recode is usable only for a small subset of NOS text formats, and |
| 3634 |
surely not with binary textual formats, like ‘UPDATE’ or ‘MODIFY’ |
| 3635 |
sources, for example. Recode is not especially suited for reading 8/12 |
| 3636 |
or 56/60 packing, yet this could easily arranged if there was a demand |
| 3637 |
for it. It does not have the ability to translate Display Code |
| 3638 |
directly, as the ASCII conversion implied by tape drivers or FTP does |
| 3639 |
the initial approximation. Recode can decode 6/12 caret notation over |
| 3640 |
Display Code already mapped to ASCII. |
| 3641 |
|
| 3642 |
* Menu: |
| 3643 |
|
| 3644 |
* Display Code:: Control Data's Display Code |
| 3645 |
* CDC-NOS:: ASCII 6/12 from NOS |
| 3646 |
* Bang-Bang:: ASCII "bang bang" |
| 3647 |
|
| 3648 |
|
| 3649 |
File: recode.info, Node: Display Code, Next: CDC-NOS, Prev: CDC, Up: CDC |
| 3650 |
|
| 3651 |
10.1 Control Data's Display Code |
| 3652 |
================================ |
| 3653 |
|
| 3654 |
This code is not available in Recode, but repeated here for reference. |
| 3655 |
This is a 6-bit code used on CDC mainframes. |
| 3656 |
|
| 3657 |
Octal display code to graphic Octal display code to octal ASCII |
| 3658 |
|
| 3659 |
00 : 20 P 40 5 60 # 00 072 20 120 40 065 60 043 |
| 3660 |
01 A 21 Q 41 6 61 [ 01 101 21 121 41 066 61 133 |
| 3661 |
02 B 22 R 42 7 62 ] 02 102 22 122 42 067 62 135 |
| 3662 |
03 C 23 S 43 8 63 % 03 103 23 123 43 070 63 045 |
| 3663 |
04 D 24 T 44 9 64 " 04 104 24 124 44 071 64 042 |
| 3664 |
05 E 25 U 45 + 65 _ 05 105 25 125 45 053 65 137 |
| 3665 |
06 F 26 V 46 - 66 ! 06 106 26 126 46 055 66 041 |
| 3666 |
07 G 27 W 47 * 67 & 07 107 27 127 47 052 67 046 |
| 3667 |
10 H 30 X 50 / 70 ' 10 110 30 130 50 057 70 047 |
| 3668 |
11 I 31 Y 51 ( 71 ? 11 111 31 131 51 050 71 077 |
| 3669 |
12 J 32 Z 52 ) 72 < 12 112 32 132 52 051 72 074 |
| 3670 |
13 K 33 0 53 $ 73 > 13 113 33 060 53 044 73 076 |
| 3671 |
14 L 34 1 54 = 74 @ 14 114 34 061 54 075 74 100 |
| 3672 |
15 M 35 2 55 75 \ 15 115 35 062 55 040 75 134 |
| 3673 |
16 N 36 3 56 , 76 ^ 16 116 36 063 56 054 76 136 |
| 3674 |
17 O 37 4 57 . 77 ; 17 117 37 064 57 056 77 073 |
| 3675 |
|
| 3676 |
In older times, ‘:’ used octal 63, and octal 0 was not a character. |
| 3677 |
The table above shows the ASCII glyph interpretation of codes 60 to 77, |
| 3678 |
yet these 16 codes were once defined differently. |
| 3679 |
|
| 3680 |
There is no explicit end of line in Display Code, and the Cyber |
| 3681 |
Record Manager introduced many new ways to represent them, the |
| 3682 |
traditional end of lines being reachable by setting ‘RT’ to ‘Z’. If |
| 3683 |
6-bit bytes in a file are sequentially counted from 1, a traditional end |
| 3684 |
of line does exist if bytes 10*N+9 and 10N+10 are both zero for a given |
| 3685 |
N, in which case these two bytes are not to be interpreted as ‘::’. |
| 3686 |
Also, up to 9 immediately preceeding zero bytes, going backward, are to |
| 3687 |
be considered as part of the end of line and not interpreted as ‘:’(1). |
| 3688 |
|
| 3689 |
---------- Footnotes ---------- |
| 3690 |
|
| 3691 |
(1) This convention replaced an older one saying that up to 4 |
| 3692 |
immediately preceeding _pairs_ of zero bytes, going backward, are to be |
| 3693 |
considered as part of the end of line and not interpreted as ‘::’. |
| 3694 |
|
| 3695 |
|
| 3696 |
File: recode.info, Node: CDC-NOS, Next: Bang-Bang, Prev: Display Code, Up: CDC |
| 3697 |
|
| 3698 |
10.2 ASCII 6/12 from NOS |
| 3699 |
======================== |
| 3700 |
|
| 3701 |
This charset is available in Recode under the name ‘CDC-NOS’, with ‘NOS’ |
| 3702 |
as an acceptable alias. |
| 3703 |
|
| 3704 |
This is one of the charsets in use on CDC Cyber NOS systems to |
| 3705 |
represent ASCII, sometimes named “NOS 6/12” code for coding ASCII. This |
| 3706 |
code is also known as “caret ASCII”. It is based on a six bits character |
| 3707 |
set in which small letters and control characters are coded using a ‘^’ |
| 3708 |
escape and, sometimes, a ‘@’ escape. |
| 3709 |
|
| 3710 |
The routines given here presume that the six bits code is already |
| 3711 |
expressed in ASCII by the communication channel, with embedded ASCII ‘^’ |
| 3712 |
and ‘@’ escapes. |
| 3713 |
|
| 3714 |
Here is a table showing which characters are being used to encode |
| 3715 |
each ASCII character. |
| 3716 |
|
| 3717 |
000 ^5 020 ^# 040 060 0 100 @A 120 P 140 @G 160 ^P |
| 3718 |
001 ^6 021 ^[ 041 ! 061 1 101 A 121 Q 141 ^A 161 ^Q |
| 3719 |
002 ^7 022 ^] 042 " 062 2 102 B 122 R 142 ^B 162 ^R |
| 3720 |
003 ^8 023 ^% 043 # 063 3 103 C 123 S 143 ^C 163 ^S |
| 3721 |
004 ^9 024 ^" 044 $ 064 4 104 D 124 T 144 ^D 164 ^T |
| 3722 |
005 ^+ 025 ^_ 045 % 065 5 105 E 125 U 145 ^E 165 ^U |
| 3723 |
006 ^- 026 ^! 046 & 066 6 106 F 126 V 146 ^F 166 ^V |
| 3724 |
007 ^* 027 ^& 047 ' 067 7 107 G 127 W 147 ^G 167 ^W |
| 3725 |
010 ^/ 030 ^' 050 ( 070 8 110 H 130 X 150 ^H 170 ^X |
| 3726 |
011 ^( 031 ^? 051 ) 071 9 111 I 131 Y 151 ^I 171 ^Y |
| 3727 |
012 ^) 032 ^< 052 * 072 @D 112 J 132 Z 152 ^J 172 ^Z |
| 3728 |
013 ^$ 033 ^> 053 + 073 ; 113 K 133 [ 153 ^K 173 ^0 |
| 3729 |
014 ^= 034 ^@ 054 , 074 < 114 L 134 \ 154 ^L 174 ^1 |
| 3730 |
015 ^ 035 ^\ 055 - 075 = 115 M 135 ] 155 ^M 175 ^2 |
| 3731 |
016 ^, 036 ^^ 056 . 076 > 116 N 136 @B 156 ^N 176 ^3 |
| 3732 |
017 ^. 037 ^; 057 / 077 ? 117 O 137 _ 157 ^O 177 ^4 |
| 3733 |
|
| 3734 |
|
| 3735 |
File: recode.info, Node: Bang-Bang, Prev: CDC-NOS, Up: CDC |
| 3736 |
|
| 3737 |
10.3 ASCII "bang bang" |
| 3738 |
====================== |
| 3739 |
|
| 3740 |
This charset is available in Recode under the name ‘Bang-Bang’. |
| 3741 |
|
| 3742 |
This code, in use on Cybers at Université de Montréal mainly, served |
| 3743 |
to code a lot of French texts. The original name of this charset is |
| 3744 |
“ASCII codé Display”. This code is also known as “Bang-bang”. It is |
| 3745 |
based on a six bits character set in which capitals, French diacritics |
| 3746 |
and a few others are coded using an ‘!’ escape followed by a single |
| 3747 |
character, and control characters using a double ‘!’ escape followed by |
| 3748 |
a single character. |
| 3749 |
|
| 3750 |
The routines given here presume that the six bits code is already |
| 3751 |
expressed in ASCII by the communication channel, with embedded ASCII ‘!’ |
| 3752 |
escapes. |
| 3753 |
|
| 3754 |
Here is a table showing which characters are being used to encode |
| 3755 |
each ASCII character. |
| 3756 |
|
| 3757 |
000 !!@ 020 !!P 040 060 0 100 @ 120 !P 140 !@ 160 P |
| 3758 |
001 !!A 021 !!Q 041 !" 061 1 101 !A 121 !Q 141 A 161 Q |
| 3759 |
002 !!B 022 !!R 042 " 062 2 102 !B 122 !R 142 B 162 R |
| 3760 |
003 !!C 023 !!S 043 # 063 3 103 !C 123 !S 143 C 163 S |
| 3761 |
004 !!D 024 !!T 044 $ 064 4 104 !D 124 !T 144 D 164 T |
| 3762 |
005 !!E 025 !!U 045 % 065 5 105 !E 125 !U 145 E 165 U |
| 3763 |
006 !!F 026 !!V 046 & 066 6 106 !F 126 !V 146 F 166 V |
| 3764 |
007 !!G 027 !!W 047 ' 067 7 107 !G 127 !W 147 G 167 W |
| 3765 |
010 !!H 030 !!X 050 ( 070 8 110 !H 130 !X 150 H 170 X |
| 3766 |
011 !!I 031 !!Y 051 ) 071 9 111 !I 131 !Y 151 I 171 Y |
| 3767 |
012 !!J 032 !!Z 052 * 072 : 112 !J 132 !Z 152 J 172 Z |
| 3768 |
013 !!K 033 !![ 053 + 073 ; 113 !K 133 [ 153 K 173 ![ |
| 3769 |
014 !!L 034 !!\ 054 , 074 < 114 !L 134 \ 154 L 174 !\ |
| 3770 |
015 !!M 035 !!] 055 - 075 = 115 !M 135 ] 155 M 175 !] |
| 3771 |
016 !!N 036 !!^ 056 . 076 > 116 !N 136 ^ 156 N 176 !^ |
| 3772 |
017 !!O 037 !!_ 057 / 077 ? 117 !O 137 _ 157 O 177 !_ |
| 3773 |
|
| 3774 |
|
| 3775 |
File: recode.info, Node: Micros, Next: Miscellaneous, Prev: CDC, Up: Top |
| 3776 |
|
| 3777 |
11 Other micro-computer charsets |
| 3778 |
******************************** |
| 3779 |
|
| 3780 |
* Menu: |
| 3781 |
|
| 3782 |
* Mac OS:: Apple's Macintosh code |
| 3783 |
* AtariST:: Atari ST code |
| 3784 |
|
| 3785 |
|
| 3786 |
File: recode.info, Node: Mac OS, Next: AtariST, Prev: Micros, Up: Micros |
| 3787 |
|
| 3788 |
11.1 Apple's Macintosh code |
| 3789 |
=========================== |
| 3790 |
|
| 3791 |
RFC 1345 brings 2 Macintosh charsets. You can discover them by using |
| 3792 |
‘grep’ over the output of ‘recode -l’: |
| 3793 |
|
| 3794 |
recode -l | grep -i mac |
| 3795 |
|
| 3796 |
Charsets ‘macintosh’ and ‘macintosh_ce’, as well as their aliases ‘mac’ |
| 3797 |
and ‘macce’ have ‘CR’ as their implied surface. |
| 3798 |
|
| 3799 |
|
| 3800 |
File: recode.info, Node: AtariST, Prev: Mac OS, Up: Micros |
| 3801 |
|
| 3802 |
11.2 Atari ST code |
| 3803 |
================== |
| 3804 |
|
| 3805 |
This charset is available in Recode under the name ‘AtariST’. |
| 3806 |
|
| 3807 |
This is the character set used on the Atari ST/TT/Falcon. This is |
| 3808 |
similar to ‘IBM-PC’, but differs in some details: it includes some more |
| 3809 |
accented characters, the graphic characters are mostly replaced by |
| 3810 |
Hebrew characters, and there is a true German ‘sharp s’ different from |
| 3811 |
Greek ‘beta’. |
| 3812 |
|
| 3813 |
About the end-of-line conversions: the canonical end-of-line on the |
| 3814 |
Atari is ‘\r\n’, but unlike ‘IBM-PC’, the OS makes no difference between |
| 3815 |
text and binary input/output; it is up to the application how to |
| 3816 |
interpret the data. In fact, most of the libraries that come with |
| 3817 |
compilers can grok both ‘\r\n’ and ‘\n’ as end of lines. Many of the |
| 3818 |
users who also have access to Unix systems prefer ‘\n’ to ease porting |
| 3819 |
Unix utilities. So, for easing reversibility, Recode tries to let ‘\r’ |
| 3820 |
undisturbed through recodings. |
| 3821 |
|
| 3822 |
|
| 3823 |
File: recode.info, Node: Miscellaneous, Next: Surfaces, Prev: Micros, Up: Top |
| 3824 |
|
| 3825 |
12 Various other charsets |
| 3826 |
************************* |
| 3827 |
|
| 3828 |
A few charsets do not fit well in the previous chapters, and are grouped |
| 3829 |
here. Some of them were added to Recode long ago, at a time this tool |
| 3830 |
was mainly meant for handling texts written in French. The bias still |
| 3831 |
shows when these charsets are linked to ‘Latin-1’ instead of the wider |
| 3832 |
‘Unicode’, but this is being corrected as Recode evolves. |
| 3833 |
|
| 3834 |
* Menu: |
| 3835 |
|
| 3836 |
* HTML:: World Wide Web representations |
| 3837 |
* LaTeX:: LaTeX macro calls |
| 3838 |
* BibTeX:: BibTeX macro calls |
| 3839 |
* Texinfo:: GNU project documentation files |
| 3840 |
* ISO 5426 and ANSEL:: Bibliographic character sets |
| 3841 |
* Vietnamese:: Vietnamese charsets |
| 3842 |
* African:: African charsets |
| 3843 |
* Others:: Cyrillic and other charsets |
| 3844 |
* Java:: Java code |
| 3845 |
* Texte:: Easy French conventions |
| 3846 |
* Mule:: Mule as a multiplexed charset |
| 3847 |
|
| 3848 |
|
| 3849 |
File: recode.info, Node: HTML, Next: LaTeX, Prev: Miscellaneous, Up: Miscellaneous |
| 3850 |
|
| 3851 |
12.1 World Wide Web representations |
| 3852 |
=================================== |
| 3853 |
|
| 3854 |
Character entities have been introduced by SGML and made widely popular |
| 3855 |
through HTML, the markup language in use for the World Wide Web, or Web |
| 3856 |
or WWW for short. For representing _unusual_ characters, HTML texts use |
| 3857 |
special sequences, beginning with an ampersand ‘&’ and ending with a |
| 3858 |
semicolon ‘;’. The sequence may itself start with a number sigh ‘#’ and |
| 3859 |
be followed by digits, so forming a “numeric character reference”, or |
| 3860 |
else be an alphabetic identifier, so forming a “character entity |
| 3861 |
reference”. |
| 3862 |
|
| 3863 |
The HTML standards have been revised into different HTML levels over |
| 3864 |
time, and the list of allowable character entities differ in them. The |
| 3865 |
later XML, meant to simplify many things, has an option |
| 3866 |
(‘standalone=yes’) which much restricts that list. The Recode library |
| 3867 |
is able to convert character references between their mnemonic form and |
| 3868 |
their numeric form, depending on aimed HTML standard level. It also |
| 3869 |
can, of course, convert between HTML and various other charsets. |
| 3870 |
|
| 3871 |
Here is a list of those HTML variants which Recode supports. Some |
| 3872 |
notes have been provided by François Yergeau <[email protected]>. |
| 3873 |
|
| 3874 |
‘XML-standalone’ |
| 3875 |
This charset is available in Recode under the name |
| 3876 |
‘XML-standalone’, with ‘h0’ as an acceptable alias. It is |
| 3877 |
documented in section 4.1 of <http://www.w3.org/TR/REC-xml>. It |
| 3878 |
only knows ‘&’, ‘>’, ‘<’, ‘"’ and ‘'’. |
| 3879 |
|
| 3880 |
‘HTML_1.1’ |
| 3881 |
This charset is available in Recode under the name ‘HTML_1.1’, with |
| 3882 |
‘h1’ as an acceptable alias. HTML 1.0 was never really documented. |
| 3883 |
|
| 3884 |
‘HTML_2.0’ |
| 3885 |
This charset is available in Recode under the name ‘HTML_2.0’, and |
| 3886 |
has ‘RFC1866’, ‘1866’ and ‘h2’ for aliases. HTML 2.0 entities are |
| 3887 |
listed in RFC 1866. Basically, there is an entity for each |
| 3888 |
_alphabetical_ character in the right part of ISO 8859-1. In |
| 3889 |
addition, there are four entities for syntax-significant ASCII |
| 3890 |
characters: ‘&’, ‘>’, ‘<’ and ‘"’. |
| 3891 |
|
| 3892 |
‘HTML-i18n’ |
| 3893 |
This charset is available in Recode under the name ‘HTML-i18n’, and |
| 3894 |
has ‘RFC2070’ and ‘2070’ for aliases. RFC 2070 added entities to |
| 3895 |
cover the whole right part of ISO 8859-1. The list is conveniently |
| 3896 |
accessible at |
| 3897 |
<http://www.alis.com:8085/ietf/html/html-latin1.sgml>. In |
| 3898 |
addition, four i18n-related entities were added: ‘‌’ |
| 3899 |
(‘‌’), ‘‍’ (‘‍’), ‘‎’ (‘‎’) and ‘‏’ |
| 3900 |
(‘‏’). |
| 3901 |
|
| 3902 |
‘HTML_3.2’ |
| 3903 |
This charset is available in Recode under the name ‘HTML_3.2’, with |
| 3904 |
‘h3’ as an acceptable alias. HTML 3.2 |
| 3905 |
(http://www.w3.org/TR/REC-html32.html) took up the full Latin-1 |
| 3906 |
list but not the i18n-related entities from RFC 2070. |
| 3907 |
|
| 3908 |
‘HTML_4.0’ |
| 3909 |
This charset is available in Recode under the name ‘HTML_4.0’, and |
| 3910 |
has ‘h4’ and ‘h’ for aliases. Beware that the particular alias ‘h’ |
| 3911 |
is not _tied_ to HTML 4.0, but to the highest HTML level supported |
| 3912 |
by Recode; so it might later represent HTML level 5 if this is ever |
| 3913 |
created. HTML 4.0 (http://www.w3.org/TR/REC-html40/) has the whole |
| 3914 |
Latin-1 list, a set of entities for symbols, mathematical symbols, |
| 3915 |
and Greek letters, and another set for markup-significant and |
| 3916 |
internationalization characters comprising the 4 ASCII entities, |
| 3917 |
the 4 i18n-related from RFC 2070 plus some more. See |
| 3918 |
<http://www.w3.org/TR/REC-html40/sgml/entities.html>. |
| 3919 |
|
| 3920 |
Printable characters from Latin-1 may be used directly in an HTML |
| 3921 |
text. However, partly because people have deficient keyboards, partly |
| 3922 |
because people want to transmit HTML texts over non 8-bit clean channels |
| 3923 |
while not using MIME, it is common (yet debatable) to use character |
| 3924 |
entity references even for Latin-1 characters, when they fall outside |
| 3925 |
ASCII (that is, when they have the 8th bit set). |
| 3926 |
|
| 3927 |
When you recode from another charset to ‘HTML’, beware that all |
| 3928 |
occurrences of double quotes, ampersands, and left or right angle |
| 3929 |
brackets are translated into special sequences. However, in practice, |
| 3930 |
people often use ampersands and angle brackets in the other charset for |
| 3931 |
introducing HTML commands, compromising it: it is not pure HTML, not it |
| 3932 |
is pure other charset. These particular translations can be rather |
| 3933 |
inconvenient, they may be specifically inhibited through the command |
| 3934 |
option ‘-d’ (*note Mixed::). |
| 3935 |
|
| 3936 |
Codes not having a mnemonic entity are output by Recode using the |
| 3937 |
‘&#NNN;’ notation, where NNN is a decimal representation of the UCS code |
| 3938 |
value. When there is an entity name for a character, it is always |
| 3939 |
preferred over a numeric character reference. ASCII printable |
| 3940 |
characters are always generated directly. So is the newline. While |
| 3941 |
reading HTML, Recode supports numeric character reference as alternate |
| 3942 |
writings, even when written as hexadecimal numbers, as in ‘�’. |
| 3943 |
This is documented in: |
| 3944 |
|
| 3945 |
http://www.w3.org/TR/REC-html40/intro/sgmltut.html#h-3.2.3 |
| 3946 |
|
| 3947 |
When Recode translates to HTML, the translation occurs according to |
| 3948 |
the HTML level as selected by the goal charset. When translating _from_ |
| 3949 |
HTML, Recode not only accepts the character entity references known at |
| 3950 |
that level, but also those of all other levels, as well as a few |
| 3951 |
alternative special sequences, to be forgiving to files using other HTML |
| 3952 |
standards. |
| 3953 |
|
| 3954 |
Recode can be used to _normalise_ an HTML file using oldish |
| 3955 |
conventions. For example, it accepts ‘&AE;’, as this once was a valid |
| 3956 |
writing, somewhere. However, it should always produce ‘Æ’ instead |
| 3957 |
of ‘&AE;’. Yet, this is not completely true. If one does: |
| 3958 |
|
| 3959 |
recode h3..h3 < INPUT |
| 3960 |
|
| 3961 |
the operation will be optimised into a mere copy, and you can get ‘&AE;’ |
| 3962 |
this way, if you had some in your input file. But if you explicitly |
| 3963 |
defeat the optimisation, like this maybe: |
| 3964 |
|
| 3965 |
recode h3..u2,u2..h3 < INPUT |
| 3966 |
|
| 3967 |
then ‘&AE;’ should be normalised into ‘Æ’ by the operation. |
| 3968 |
|
| 3969 |
|
| 3970 |
File: recode.info, Node: LaTeX, Next: BibTeX, Prev: HTML, Up: Miscellaneous |
| 3971 |
|
| 3972 |
12.2 LaTeX macro calls |
| 3973 |
====================== |
| 3974 |
|
| 3975 |
This charset is available in Recode under the name ‘LaTeX’ and has |
| 3976 |
‘ltex’ as an alias. It is used for ASCII files coded to be read by |
| 3977 |
LaTeX or, in certain cases, by TeX. |
| 3978 |
|
| 3979 |
Whenever you recode from another charset to ‘LaTeX’, beware that all |
| 3980 |
occurrences of backslashes ‘\’ are translated into the string |
| 3981 |
‘\backslash{}’. However, in practice, people often use backslashes in |
| 3982 |
the other charset for introducing TeX commands, compromising it: it is |
| 3983 |
not pure TeX, nor it is pure other charset. This translation of |
| 3984 |
backslashes into ‘\backslash{}’ can be rather inconvenient, it may be |
| 3985 |
inhibited through the command option ‘-d’ (*note Mixed::). |
| 3986 |
|
| 3987 |
|
| 3988 |
File: recode.info, Node: BibTeX, Next: Texinfo, Prev: LaTeX, Up: Miscellaneous |
| 3989 |
|
| 3990 |
12.3 BibTeX macro calls |
| 3991 |
======================= |
| 3992 |
|
| 3993 |
This charset is available in Recode under the name ‘BibTeX’ with aliases |
| 3994 |
‘bibtex’ and ‘btex’. It is used for ASCII files coded to be read by |
| 3995 |
BibTeX or, in certain cases, by LaTeX or TeX. |
| 3996 |
|
| 3997 |
This charset is very similar to ‘LaTeX’. The only difference is that |
| 3998 |
diacritics are enclosed between ‘{}’. Refer to ‘LaTeX’ charset for |
| 3999 |
further information. *Note LaTeX::. |
| 4000 |
|
| 4001 |
|
| 4002 |
File: recode.info, Node: Texinfo, Next: ISO 5426 and ANSEL, Prev: BibTeX, Up: Miscellaneous |
| 4003 |
|
| 4004 |
12.4 GNU project documentation files |
| 4005 |
==================================== |
| 4006 |
|
| 4007 |
This charset is available in Recode under the name ‘Texinfo’ and has |
| 4008 |
‘texi’ and ‘ti’ for aliases. It is used by the GNU project for its |
| 4009 |
documentation. Texinfo files may be converted into Info files by the |
| 4010 |
‘makeinfo’ program and into nice printed manuals by the TeX system. |
| 4011 |
|
| 4012 |
Even if Recode may transform other charsets to Texinfo, it may not |
| 4013 |
read Texinfo files yet. In these times, usages are also changing |
| 4014 |
between versions of Texinfo, and Recode only partially succeeds in |
| 4015 |
correctly following these changes. So, for now, Texinfo support in |
| 4016 |
Recode should be considered as work still in progress (!). |
| 4017 |
|
| 4018 |
|
| 4019 |
File: recode.info, Node: ISO 5426 and ANSEL, Next: Vietnamese, Prev: Texinfo, Up: Miscellaneous |
| 4020 |
|
| 4021 |
12.5 Bibliographic character sets |
| 4022 |
================================= |
| 4023 |
|
| 4024 |
These two character sets are intended to work with ASCII for exchange of |
| 4025 |
bibliographic information. |
| 4026 |
|
| 4027 |
|
| 4028 |
File: recode.info, Node: Vietnamese, Next: African, Prev: ISO 5426 and ANSEL, Up: Miscellaneous |
| 4029 |
|
| 4030 |
12.6 Vietnamese charsets |
| 4031 |
======================== |
| 4032 |
|
| 4033 |
We are currently trying the implementation, in Recode, of a few |
| 4034 |
character sets and transliterated forms to handle the Vietnamese |
| 4035 |
language. They are quite briefly summarised, here. |
| 4036 |
|
| 4037 |
‘TCVN’ |
| 4038 |
The TCVN charset has an incomplete name. It might be one of the |
| 4039 |
three charset ‘VN1’, ‘VN2’ or ‘VN3’. Yes ‘VN2’ might be a second |
| 4040 |
version of ‘VISCII’. To be clarified. |
| 4041 |
|
| 4042 |
‘VISCII’ |
| 4043 |
This is an 8-bit character set which seems to be rather popular for |
| 4044 |
writing Vietnamese. |
| 4045 |
|
| 4046 |
‘VPS’ |
| 4047 |
This is an 8-bit character set for Vietnamese. No much reference. |
| 4048 |
|
| 4049 |
‘VIQR’ |
| 4050 |
The VIQR convention is a 7-bit, ‘ASCII’ transliteration for |
| 4051 |
Vietnamese. |
| 4052 |
|
| 4053 |
‘VNI’ |
| 4054 |
The VNI convention is a 8-bit, ‘Latin-1’ transliteration for |
| 4055 |
Vietnamese. |
| 4056 |
|
| 4057 |
Still lacking for Vietnamese in Recode, are the charsets ‘CP1129’ and |
| 4058 |
‘CP1258’. |
| 4059 |
|
| 4060 |
|
| 4061 |
File: recode.info, Node: African, Next: Others, Prev: Vietnamese, Up: Miscellaneous |
| 4062 |
|
| 4063 |
12.7 African charsets |
| 4064 |
===================== |
| 4065 |
|
| 4066 |
Some African character sets are available for a few languages, when |
| 4067 |
these are heavily used in countries where French is also currently |
| 4068 |
spoken. |
| 4069 |
|
| 4070 |
One African charset is usable for Bambara, Ewondo and Fulfude, as |
| 4071 |
well as for French. This charset is available in Recode under the name |
| 4072 |
‘AFRFUL-102-BPI_OCIL’. Accepted aliases are ‘bambara’, ‘bra’, ‘ewondo’ |
| 4073 |
and ‘fulfude’. Transliterated forms of the same are available under the |
| 4074 |
name ‘AFRFUL-103-BPI_OCIL’. Accepted aliases are ‘t-bambara’, ‘t-bra’, |
| 4075 |
‘t-ewondo’ and ‘t-fulfude’. |
| 4076 |
|
| 4077 |
Another African charset is usable for Lingala, Sango and Wolof, as |
| 4078 |
well as for French. This charset is available in Recode under the name |
| 4079 |
‘AFRLIN-104-BPI_OCIL’. Accepted aliases are ‘lingala’, ‘lin’, ‘sango’ |
| 4080 |
and ‘wolof’. Transliterated forms of the same are available under the |
| 4081 |
name ‘AFRLIN-105-BPI_OCIL’. Accepted aliases are ‘t-lingala’, ‘t-lin’, |
| 4082 |
‘t-sango’ and ‘t-wolof’. |
| 4083 |
|
| 4084 |
To ease exchange with ‘ISO-8859-1’, there is a charset conveying |
| 4085 |
transliterated forms for Latin-1 in a way which is compatible with the |
| 4086 |
other African charsets in this series. This charset is available in |
| 4087 |
Recode under the name ‘AFRL1-101-BPI_OCIL’. Accepted aliases are |
| 4088 |
‘t-fra’ and ‘t-francais’. |
| 4089 |
|
| 4090 |
|
| 4091 |
File: recode.info, Node: Others, Next: Java, Prev: African, Up: Miscellaneous |
| 4092 |
|
| 4093 |
12.8 Cyrillic and other charsets |
| 4094 |
================================ |
| 4095 |
|
| 4096 |
The following Cyrillic charsets are already available in Recode through |
| 4097 |
RFC 1345 tables: ‘CP1251’ with aliases ‘1251’, ‘ ms-cyrl’ and |
| 4098 |
‘windows-1251’; ‘CSN_369103’ with aliases ‘ISO-IR-139’ and ‘KOI8_L2’; |
| 4099 |
‘ECMA-cyrillic’ with aliases ‘ECMA-113’, ‘ECMA-113:1986’ and |
| 4100 |
‘iso-ir-111’, ‘IBM880’ with aliases ‘880’, ‘CP880’ and |
| 4101 |
‘EBCDIC-Cyrillic’; ‘INIS-cyrillic’ with alias ‘iso-ir-51’; ‘ISO-8859-5’ |
| 4102 |
with aliases ‘cyrillic’, ‘ ISO-8859-5:1988’ and ‘iso-ir-144’; ‘KOI-7’; |
| 4103 |
‘KOI-8’ with alias ‘GOST_19768-74’; ‘KOI8-R’; ‘KOI8-RU’ and finally |
| 4104 |
‘KOI8-U’. |
| 4105 |
|
| 4106 |
There seems to remain some confusion in Roman charsets for Cyrillic |
| 4107 |
languages, and because a few users requested it repeatedly, Recode now |
| 4108 |
offers special services in that area. Consider these charsets as |
| 4109 |
experimental and debatable, as the extraneous tables describing them are |
| 4110 |
still a bit fuzzy or non-standard. Hopefully, in the long run, these |
| 4111 |
charsets will be covered in Keld Simonsen's works to the satisfaction of |
| 4112 |
everybody, and this section will merely disappear. |
| 4113 |
|
| 4114 |
‘KEYBCS2’ |
| 4115 |
This charset is available under the name ‘KEYBCS2’, with |
| 4116 |
‘Kamenicky’ as an accepted alias. |
| 4117 |
|
| 4118 |
‘CORK’ |
| 4119 |
This charset is available under the name ‘CORK’, with ‘T1’ as an |
| 4120 |
accepted alias. |
| 4121 |
|
| 4122 |
‘KOI-8_CS2’ |
| 4123 |
This charset is available under the name ‘KOI-8_CS2’. |
| 4124 |
|
| 4125 |
|
| 4126 |
File: recode.info, Node: Java, Next: Texte, Prev: Others, Up: Miscellaneous |
| 4127 |
|
| 4128 |
12.9 Java code |
| 4129 |
============== |
| 4130 |
|
| 4131 |
This charset is available under the name ‘Java’, and should be |
| 4132 |
considered experimental for now. |
| 4133 |
|
| 4134 |
ASCII characters represent themselves. Character outside ASCII are |
| 4135 |
coded as ‘\uNNNN’, where ‘NNNN’ stands for the four-digit hexadecimal |
| 4136 |
value of the character within Unicode. The canonical representation |
| 4137 |
uses lower case for the ‘u’ prefix and for the hexadecimal digits, yet |
| 4138 |
Recode also accepts upper case. |
| 4139 |
|
| 4140 |
There is currently no attempt to distinguish Java comments from Java |
| 4141 |
strings while the recoding goes, and this may be corrected some day. |
| 4142 |
|
| 4143 |
|
| 4144 |
File: recode.info, Node: Texte, Next: Mule, Prev: Java, Up: Miscellaneous |
| 4145 |
|
| 4146 |
12.10 Easy French conventions |
| 4147 |
============================= |
| 4148 |
|
| 4149 |
This charset is available in Recode under the name ‘Texte’ and has |
| 4150 |
‘txte’ for an alias. It is a seven bits code, identical to ‘ASCII-BS’, |
| 4151 |
save for French diacritics which are noted using a slightly different |
| 4152 |
convention. |
| 4153 |
|
| 4154 |
At text entry time, these conventions provide a little speed up. At |
| 4155 |
read time, they slightly improve the readability over a few alternate |
| 4156 |
ways of coding diacritics. Of course, it would better to have a |
| 4157 |
specialised keyboard to make direct eight bits entries and fonts for |
| 4158 |
immediately displaying eight bit ISO Latin-1 characters. But not |
| 4159 |
everybody is so fortunate. In a few mailing environments, and sadly |
| 4160 |
enough, it still happens that the eight bit is often willing-fully |
| 4161 |
destroyed. |
| 4162 |
|
| 4163 |
Easy French has been in use in France for a while. I only slightly |
| 4164 |
adapted it (the diaeresis option) to make it more comfortable to several |
| 4165 |
usages in Québec originating from Université de Montréal. In fact, the |
| 4166 |
main problem for me was not to necessarily to invent Easy French, but to |
| 4167 |
recognise the "best" convention to use, (best is not being defined, |
| 4168 |
here) and to try to solve the main pitfalls associated with the selected |
| 4169 |
convention. Shortly said, we have: |
| 4170 |
|
| 4171 |
‘e'’ |
| 4172 |
for ‘e’ (and some other vowels) with an acute accent, |
| 4173 |
‘e`’ |
| 4174 |
for ‘e’ (and some other vowels) with a grave accent, |
| 4175 |
‘e^’ |
| 4176 |
for ‘e’ (and some other vowels) with a circumflex accent, |
| 4177 |
‘e"’ |
| 4178 |
for ‘e’ (and some other vowels) with a diaeresis, |
| 4179 |
‘c,’ |
| 4180 |
for ‘c’ with a cedilla. |
| 4181 |
|
| 4182 |
There is no attempt at expressing the ‘ae’ and ‘oe’ diphthongs. French |
| 4183 |
also uses tildes over ‘n’ and ‘a’, but seldomly, and this is not |
| 4184 |
represented either. In some countries, ‘:’ is used instead of ‘"’ to |
| 4185 |
mark diaeresis. Recode supports only one convention per call, depending |
| 4186 |
on the ‘-c’ option of the ‘recode’ command. French quotes (sometimes |
| 4187 |
called "angle quotes") are noted the same way English quotes are noted |
| 4188 |
in TeX, _id est_ by ‘``’ and ‘''’. No effort has been put to preserve |
| 4189 |
Latin ligatures (‘æ’, ‘œ’) which are representable in several other |
| 4190 |
charsets. So, these ligatures may be lost through Easy French |
| 4191 |
conventions. |
| 4192 |
|
| 4193 |
The convention is prone to losing information, because the diacritic |
| 4194 |
meaning overloads some characters that already have other uses. To |
| 4195 |
alleviate this, some knowledge of the French language is boosted into |
| 4196 |
the recognition routines. So, the following subtleties are |
| 4197 |
systematically obeyed by the various recognisers. |
| 4198 |
|
| 4199 |
1. A comma which follows a ‘c’ is interpreted as a cedilla only if it |
| 4200 |
is followed by one of the vowels ‘a’, ‘o’ or ‘u’. |
| 4201 |
|
| 4202 |
2. A single quote which follows a ‘e’ does not necessarily means an |
| 4203 |
acute accent if it is followed by a single other one. For example: |
| 4204 |
|
| 4205 |
‘e'’ |
| 4206 |
will give an ‘e’ with an acute accent. |
| 4207 |
‘e''’ |
| 4208 |
will give a simple ‘e’, with a closing quotation mark. |
| 4209 |
‘e'''’ |
| 4210 |
will give an ‘e’ with an acute accent, followed by a closing |
| 4211 |
quotation mark. |
| 4212 |
|
| 4213 |
There is a problem induced by this convention if there are English |
| 4214 |
quotations with a French text. In sentences like: |
| 4215 |
|
| 4216 |
There's a meeting at Archie's restaurant. |
| 4217 |
|
| 4218 |
the single quotes will be mistaken twice for acute accents. So |
| 4219 |
English contractions and suffix possessives could be mangled. |
| 4220 |
|
| 4221 |
3. A double quote or colon, depending on ‘-c’ option, which follows a |
| 4222 |
vowel is interpreted as diaeresis only if it is followed by another |
| 4223 |
letter. But there are in French several words that _end_ with a |
| 4224 |
diaeresis, and the Recode library is aware of them. There are |
| 4225 |
words ending in "igue", either feminine words without a relative |
| 4226 |
masculine (besaiguë and ciguë), or feminine words with a relative |
| 4227 |
masculine(1) (aiguë, ambiguë, contiguë, exiguë, subaiguë and |
| 4228 |
suraiguë). There are also words not ending in "igue", but instead, |
| 4229 |
either ending by "i"(2) (ai", congai", goi", hai"kai", inoui", |
| 4230 |
sai", samurai", thai" and tokai"), ending by "e" (canoë) or ending |
| 4231 |
by "u"(3) (Esaü). |
| 4232 |
|
| 4233 |
Just to complete this topic, note that it would be wrong to make a |
| 4234 |
rule for all words ending in "igue" as needing a diaerisis, as |
| 4235 |
there are counter-examples (becfigue, bèsigue, bigue, bordigue, |
| 4236 |
bourdigue, brigue, contre-digue, digue, d'intrigue, fatigue, figue, |
| 4237 |
garrigue, gigue, igue, intrigue, ligue, prodigue, sarigue and |
| 4238 |
zigue). |
| 4239 |
|
| 4240 |
---------- Footnotes ---------- |
| 4241 |
|
| 4242 |
(1) There are supposed to be seven words in this case. So, one is |
| 4243 |
missing. |
| 4244 |
|
| 4245 |
(2) Look at one of the following sentences (the second has to be |
| 4246 |
interpreted with the ‘-c’ option): |
| 4247 |
|
| 4248 |
"Ai"e! Voici le proble`me que j'ai" |
| 4249 |
Ai:e! Voici le proble`me que j'ai: |
| 4250 |
|
| 4251 |
There is an ambiguity between an ai", the small animal, and the |
| 4252 |
indicative future of _avoir_ (first person singular), when followed by |
| 4253 |
what could be a diaeresis mark. Hopefully, the case is solved by the |
| 4254 |
fact that an apostrophe always precedes the verb and almost never the |
| 4255 |
animal. |
| 4256 |
|
| 4257 |
(3) I did not pay attention to proper nouns, but this one showed up |
| 4258 |
as being fairly evident. |
| 4259 |
|
| 4260 |
|
| 4261 |
File: recode.info, Node: Mule, Prev: Texte, Up: Miscellaneous |
| 4262 |
|
| 4263 |
12.11 Mule as a multiplexed charset |
| 4264 |
=================================== |
| 4265 |
|
| 4266 |
This version of Recode barely starts supporting multiplexed or |
| 4267 |
super-charsets, that is, those encoding methods by which a single text |
| 4268 |
stream may contain a combination of more than one constituent charset. |
| 4269 |
The only multiplexed charset in Recode is ‘Mule’, and even then, it is |
| 4270 |
only very partially implemented: the only correspondence available is |
| 4271 |
with ‘Latin-1’. The author quickly implemented this only because he |
| 4272 |
needed this for himself. However, it is intended that Mule support to |
| 4273 |
become more real in subsequent releases of Recode. |
| 4274 |
|
| 4275 |
Multiplexed charsets are not to be confused with mixed charset texts |
| 4276 |
(*note Mixed::). For mixed charset input, the rules allowing to |
| 4277 |
distinguish which charset is current, at any given place, are kind of |
| 4278 |
informal, and driven from the semantics of what the file contains. On |
| 4279 |
the other side, multiplexed charsets are _designed_ to be interpreted |
| 4280 |
fairly precisely, and quite independently of any informational context. |
| 4281 |
|
| 4282 |
The spelling ‘Mule’ originally stood for ‘_mul_tilingual |
| 4283 |
_e_nhancement to GNU Emacs’, it is the result of a collective effort |
| 4284 |
orchestrated by Handa Ken'ichi since 1993. When ‘Mule’ got rewritten in |
| 4285 |
the main development stream of GNU Emacs 20, the FSF renamed it ‘MULE’, |
| 4286 |
meaning ‘_mul_tilingual _e_nvironment in GNU Emacs’. Even if the |
| 4287 |
charset ‘Mule’ is meant to stay internal to GNU Emacs, it sometimes |
| 4288 |
breaks loose in external files, and as a consequence, a recoding tool is |
| 4289 |
sometimes needed. Within Emacs, ‘Mule’ comes with ‘Leim’, which stands |
| 4290 |
for ‘_l_ibraries of _e_macs _i_nput _m_ethods’. One of these libraries |
| 4291 |
is named ‘quail’(1). |
| 4292 |
|
| 4293 |
---------- Footnotes ---------- |
| 4294 |
|
| 4295 |
(1) Usually, quail means quail egg in Japanese, while egg alone is |
| 4296 |
usually chicken egg. Both quail egg and chicken egg are popular food in |
| 4297 |
Japan. The ‘quail’ input system has been named because it is smaller |
| 4298 |
than the previous ‘EGG’ system. As for ‘EGG’, it is the translation of |
| 4299 |
‘TAMAGO’. This word comes from the Japanese sentence ‘_ta_kusan |
| 4300 |
_ma_tasete _go_mennasai’, meaning ‘sorry to have let you wait so long’. |
| 4301 |
Of course, the publication of ‘EGG’ has been delayed many times... |
| 4302 |
(Story by Takahashi Naoto) |
| 4303 |
|
| 4304 |
|
| 4305 |
File: recode.info, Node: Surfaces, Next: Internals, Prev: Miscellaneous, Up: Top |
| 4306 |
|
| 4307 |
13 All about surfaces |
| 4308 |
********************* |
| 4309 |
|
| 4310 |
A “surface” is the varnish added over a charset so it fits in actual |
| 4311 |
bits and bytes. How end of lines are exactly encoded is not really |
| 4312 |
pertinent to the charset, and so, there is surface for end of lines. |
| 4313 |
‘Base64’ is also a surface, as we may encode any charset in it. Other |
| 4314 |
examples would DES enciphering, or gzip compression (even if Recode does |
| 4315 |
not offer them currently): these are ways to give a real life to |
| 4316 |
theoretical charsets. |
| 4317 |
|
| 4318 |
The “trivial surface” consists of using a fixed number of bits (often |
| 4319 |
eight) for each character, the bits together hold the integer value of |
| 4320 |
the index for the character in its charset table. There are many kinds |
| 4321 |
of surfaces, beyond the trivial one, all having the purpose of |
| 4322 |
increasing selected qualities for the storage or transmission. For |
| 4323 |
example, surfaces might increase the resistance to channel limits |
| 4324 |
(‘Base64’), the transmission speed (‘gzip’), the information privacy |
| 4325 |
(‘DES’), the conformance to operating system conventions (‘CR-LF’), the |
| 4326 |
blocking into records (‘VB’), and surely other things as well(1). Many |
| 4327 |
surfaces may be applied to a stream of characters from a charset, the |
| 4328 |
order of application of surfaces is important, and surfaces should be |
| 4329 |
removed in the reverse order of their application. |
| 4330 |
|
| 4331 |
Even if surfaces may generally be applied to various charsets, some |
| 4332 |
surfaces were specifically designed for a particular charset, and would |
| 4333 |
not make much sense if applied to other charsets. In such cases, these |
| 4334 |
conceptual surfaces have been implemented as Recode charsets, instead of |
| 4335 |
as surfaces. This choice yields to cleaner syntax and usage. *Note |
| 4336 |
Universal::. |
| 4337 |
|
| 4338 |
Surfaces are implemented within Recode as special charsets which may |
| 4339 |
only transform to or from the ‘data’ special charset. Clever users may |
| 4340 |
use this knowledge for writing surface names in requests exactly as if |
| 4341 |
they were pure charsets, when the only need is to change surfaces |
| 4342 |
without any kind of recoding between real charsets. In such contexts |
| 4343 |
‘data’ may also be used as if it were some kind of generic, anonymous |
| 4344 |
charset: the request ‘data..SURFACE’ merely adds the given SURFACE, |
| 4345 |
while the request ‘SURFACE..data’ removes it. |
| 4346 |
|
| 4347 |
This chapter presents all surfaces currently available. |
| 4348 |
|
| 4349 |
* Menu: |
| 4350 |
|
| 4351 |
* Permutations:: Permuting groups of bytes |
| 4352 |
* End lines:: Representation for end of lines |
| 4353 |
* MIME:: MIME contents encodings |
| 4354 |
* Dump:: Interpreted character dumps |
| 4355 |
* Test:: Artificial data for testing |
| 4356 |
|
| 4357 |
---------- Footnotes ---------- |
| 4358 |
|
| 4359 |
(1) These are mere examples to explain the concept, Recode only has |
| 4360 |
‘Base64’ and ‘CR-LF’, actually. |
| 4361 |
|
| 4362 |
|
| 4363 |
File: recode.info, Node: Permutations, Next: End lines, Prev: Surfaces, Up: Surfaces |
| 4364 |
|
| 4365 |
13.1 Permuting groups of bytes |
| 4366 |
============================== |
| 4367 |
|
| 4368 |
A permutation is a surface transformation which reorders groups of |
| 4369 |
eight-bit bytes. A _21_ permutation exchanges pairs of successive |
| 4370 |
bytes. If the text contains an odd number of bytes, the last byte is |
| 4371 |
merely copied. An _4321_ permutation inverts the order of quadruples of |
| 4372 |
bytes. If the text does not contains a multiple of four bytes, the |
| 4373 |
remaining bytes are nevertheless permuted as _321_ if there are three |
| 4374 |
bytes, _21_ if there are two bytes, or merely copied otherwise. |
| 4375 |
|
| 4376 |
‘21’ |
| 4377 |
This surface is available in Recode under the name ‘21-Permutation’ |
| 4378 |
and has ‘swabytes’ for an alias. |
| 4379 |
|
| 4380 |
‘4321’ |
| 4381 |
This surface is available in Recode under the name |
| 4382 |
‘4321-Permutation’. |
| 4383 |
|
| 4384 |
|
| 4385 |
File: recode.info, Node: End lines, Next: MIME, Prev: Permutations, Up: Surfaces |
| 4386 |
|
| 4387 |
13.2 Representation for end of lines |
| 4388 |
==================================== |
| 4389 |
|
| 4390 |
The same charset might slightly differ, from one system to another, for |
| 4391 |
the single fact that end of lines are not represented identically on all |
| 4392 |
systems. The representation for an end of line within Recode is the |
| 4393 |
‘ASCII’ or ‘UCS’ code with value 10, or ‘LF’. Other conventions for |
| 4394 |
representing end of lines are available through surfaces. |
| 4395 |
|
| 4396 |
‘CR’ |
| 4397 |
This convention is popular on Apple's Macintosh machines. When |
| 4398 |
this surface is applied, each line is terminated by ‘CR’, which has |
| 4399 |
‘ASCII’ value 13. Unless the library is operating in strict mode, |
| 4400 |
adding or removing the surface will in fact _exchange_ ‘CR’ and |
| 4401 |
‘LF’, for better reversibility. However, in strict mode, the |
| 4402 |
exchange does not happen, any ‘CR’ will be copied verbatim while |
| 4403 |
applying the surface, and any ‘LF’ will be copied verbatim while |
| 4404 |
removing it. |
| 4405 |
|
| 4406 |
This surface is available in Recode under the name ‘CR’, it does |
| 4407 |
not have any aliases. This is the implied surface for the Apple |
| 4408 |
Macintosh related charsets. |
| 4409 |
|
| 4410 |
‘CR-LF’ |
| 4411 |
This convention is popular on Microsoft systems running on IBM PCs |
| 4412 |
and compatible. When this surface is applied, each line is |
| 4413 |
terminated by a sequence of two characters: one ‘CR’ followed by |
| 4414 |
one ‘LF’, in that order. |
| 4415 |
|
| 4416 |
For compatibility with oldish MS-DOS systems, removing a ‘CR-LF’ |
| 4417 |
surface will discard the first encountered ‘C-z’, which has ‘ASCII’ |
| 4418 |
value 26, and everything following it in the text. Adding this |
| 4419 |
surface will not, however, append a ‘C-z’ to the result. |
| 4420 |
|
| 4421 |
This surface is available in Recode under the name ‘CR-LF’ and has |
| 4422 |
‘cl’ for an alias. This is the implied surface for the IBM or |
| 4423 |
Microsoft related charsets or code pages. |
| 4424 |
|
| 4425 |
Some other charsets might have their own representation for an end of |
| 4426 |
line, which is different from ‘LF’. For example, this is the case of |
| 4427 |
various ‘EBCDIC’ charsets, or ‘Icon-QNX’. The recoding of end of lines |
| 4428 |
is intimately tied into such charsets, it is not available separately as |
| 4429 |
surfaces. |
| 4430 |
|
| 4431 |
|
| 4432 |
File: recode.info, Node: MIME, Next: Dump, Prev: End lines, Up: Surfaces |
| 4433 |
|
| 4434 |
13.3 MIME contents encodings |
| 4435 |
============================ |
| 4436 |
|
| 4437 |
RFC 2045 defines two 7-bit surfaces, meant to prepare 8-bit messages for |
| 4438 |
transmission. Base64 is especially usable for binary entities, while |
| 4439 |
Quoted-Printable is especially usable for text entities, in those case |
| 4440 |
the lower 128 characters of the underlying charset coincide with ASCII. |
| 4441 |
|
| 4442 |
‘Base64’ |
| 4443 |
This surface is available in Recode under the name ‘Base64’, with |
| 4444 |
‘b64’ and ‘64’ as acceptable aliases. |
| 4445 |
|
| 4446 |
‘Quoted-Printable’ |
| 4447 |
This surface is available in Recode under the name |
| 4448 |
‘Quoted-Printable’, with ‘quote-printable’ and ‘QP’ as acceptable |
| 4449 |
aliases. |
| 4450 |
|
| 4451 |
Note that ‘UTF-7’, which may be also considered as a MIME surface, is |
| 4452 |
provided as a genuine charset instead, as it necessary relates to |
| 4453 |
‘UCS-2’ and nothing else. *Note UTF-7::. |
| 4454 |
|
| 4455 |
A little historical note, also showing the three levels of acceptance |
| 4456 |
of Internet standards. MIME changed from a "Proposed Standard" |
| 4457 |
(RFC 1341-1344, 1992) to a "Draft Standard" (RFC 1521-1523) in 1993, and |
| 4458 |
was _recycled_ as a "Draft Standard" in 1996-11. It is not yet a "Full |
| 4459 |
Standard". |
| 4460 |
|
| 4461 |
|
| 4462 |
File: recode.info, Node: Dump, Next: Test, Prev: MIME, Up: Surfaces |
| 4463 |
|
| 4464 |
13.4 Interpreted character dumps |
| 4465 |
================================ |
| 4466 |
|
| 4467 |
Dumps are surfaces meant to express, in ways which are a bit more |
| 4468 |
readable, the bit patterns used to represent characters. They allow the |
| 4469 |
inspection or debugging of character streams, but also, they may assist |
| 4470 |
a bit the production of C source code which, once compiled, would hold |
| 4471 |
in memory a copy of the original coding. However, Recode does not |
| 4472 |
attempt, in any way, to produce complete C source files in dumps. User |
| 4473 |
hand editing or ‘Makefile’ trickery is still needed for adding missing |
| 4474 |
lines. Dumps may be given in decimal, hexadecimal and octal, and be |
| 4475 |
based over chunks of either one, two or four eight-bit bytes. |
| 4476 |
Formatting has been chosen to respect the C language syntax for number |
| 4477 |
constants, with commas and newlines inserted appropriately. |
| 4478 |
|
| 4479 |
However, when dumping two or four byte chunks, the last chunk may be |
| 4480 |
incomplete. This is observable through the usage of narrower expression |
| 4481 |
for that last chunk only. Such a shorter chunk would not be compiled |
| 4482 |
properly within a C initialiser, as all members of an array share a |
| 4483 |
single type, and so, have identical sizes. |
| 4484 |
|
| 4485 |
‘Octal-1’ |
| 4486 |
This surface corresponds to an octal expression of each input byte. |
| 4487 |
|
| 4488 |
It is available in Recode under the name ‘Octal-1’, with ‘o1’ and |
| 4489 |
‘o’ as acceptable aliases. |
| 4490 |
|
| 4491 |
‘Octal-2’ |
| 4492 |
This surface corresponds to an octal expression of each pair of |
| 4493 |
input bytes, except for the last pair, which may be short. |
| 4494 |
|
| 4495 |
It is available in Recode under the name ‘Octal-2’ and has ‘o2’ for |
| 4496 |
an alias. |
| 4497 |
|
| 4498 |
‘Octal-4’ |
| 4499 |
This surface corresponds to an octal expression of each quadruple |
| 4500 |
of input bytes, except for the last quadruple, which may be short. |
| 4501 |
|
| 4502 |
It is available in Recode under the name ‘Octal-4’ and has ‘o4’ for |
| 4503 |
an alias. |
| 4504 |
|
| 4505 |
‘Decimal-1’ |
| 4506 |
This surface corresponds to an decimal expression of each input |
| 4507 |
byte. |
| 4508 |
|
| 4509 |
It is available in Recode under the name ‘Decimal-1’, with ‘d1’ and |
| 4510 |
‘d’ as acceptable aliases. |
| 4511 |
|
| 4512 |
‘Decimal-2’ |
| 4513 |
This surface corresponds to an decimal expression of each pair of |
| 4514 |
input bytes, except for the last pair, which may be short. |
| 4515 |
|
| 4516 |
It is available in Recode under the name ‘Decimal-2’ and has ‘d2’ |
| 4517 |
for an alias. |
| 4518 |
|
| 4519 |
‘Decimal-4’ |
| 4520 |
This surface corresponds to an decimal expression of each quadruple |
| 4521 |
of input bytes, except for the last quadruple, which may be short. |
| 4522 |
|
| 4523 |
It is available in Recode under the name ‘Decimal-4’ and has ‘d4’ |
| 4524 |
for an alias. |
| 4525 |
|
| 4526 |
‘Hexadecimal-1’ |
| 4527 |
This surface corresponds to an hexadecimal expression of each input |
| 4528 |
byte. |
| 4529 |
|
| 4530 |
It is available in Recode under the name ‘Hexadecimal-1’, with ‘x1’ |
| 4531 |
and ‘x’ as acceptable aliases. |
| 4532 |
|
| 4533 |
‘Hexadecimal-2’ |
| 4534 |
This surface corresponds to an hexadecimal expression of each pair |
| 4535 |
of input bytes, except for the last pair, which may be short. |
| 4536 |
|
| 4537 |
It is available in Recode under the name ‘Hexadecimal-2’, with ‘x2’ |
| 4538 |
for an alias. |
| 4539 |
|
| 4540 |
‘Hexadecimal-4’ |
| 4541 |
This surface corresponds to an hexadecimal expression of each |
| 4542 |
quadruple of input bytes, except for the last quadruple, which may |
| 4543 |
be short. |
| 4544 |
|
| 4545 |
It is available in Recode under the name ‘Hexadecimal-4’, with ‘x4’ |
| 4546 |
for an alias. |
| 4547 |
|
| 4548 |
When removing a dump surface, that is, when reading a dump results |
| 4549 |
back into a sequence of bytes, the narrower expression for a short last |
| 4550 |
chunk is recognised, so dumping is a fully reversible operation. |
| 4551 |
However, in case you want to produce dumps by other means than through |
| 4552 |
Recode, beware that for decimal dumps, the library has to rely on the |
| 4553 |
number of spaces to establish the original byte size of the chunk. |
| 4554 |
|
| 4555 |
Although the library might report reversibility errors, removing a |
| 4556 |
dump surface is a rather forgiving process: one may mix bases, group a |
| 4557 |
variable number of data per source line, or use shorter chunks in places |
| 4558 |
other than at the far end. Also, source lines not beginning with a |
| 4559 |
number are skipped. So, Recode should often be able to read a whole C |
| 4560 |
header file, wrapping the results of a previous dump, and regenerate the |
| 4561 |
original byte string. |
| 4562 |
|
| 4563 |
|
| 4564 |
File: recode.info, Node: Test, Prev: Dump, Up: Surfaces |
| 4565 |
|
| 4566 |
13.5 Artificial data for testing |
| 4567 |
================================ |
| 4568 |
|
| 4569 |
A few pseudo-surfaces exist to generate debugging data out of thin air. |
| 4570 |
These surfaces are only meant for the expert Recode user, and are only |
| 4571 |
useful in a few contexts, like for generating binary permutations from |
| 4572 |
the recoding or acting on them. |
| 4573 |
|
| 4574 |
Debugging surfaces, _when removed_, insert their generated data at |
| 4575 |
the beginning of the output stream, and copy all the input stream after |
| 4576 |
the generated data, unchanged. This strange removal constraint comes |
| 4577 |
from the fact that debugging surfaces are usually specified in the |
| 4578 |
_before_ position instead of the _after_ position within a request. |
| 4579 |
With debugging surfaces, one often recodes file ‘/dev/null’ in filter |
| 4580 |
mode. Specifying many debugging surfaces at once has an accumulation |
| 4581 |
effect on the output, and since surfaces are removed from right to left, |
| 4582 |
each generating its data at the beginning of previous output, the net |
| 4583 |
effect is an _impression_ that debugging surfaces are generated from |
| 4584 |
left to right, each appending to the result of the previous. In any |
| 4585 |
case, any real input data gets appended after what was generated. |
| 4586 |
|
| 4587 |
‘test7’ |
| 4588 |
When removed, this surface produces 128 single bytes, the first |
| 4589 |
having value 0, the second having value 1, and so forth until all |
| 4590 |
128 values have been generated. |
| 4591 |
|
| 4592 |
‘test8’ |
| 4593 |
When removed, this surface produces 256 single bytes, the first |
| 4594 |
having value 0, the second having value 1, and so forth until all |
| 4595 |
256 values have been generated. |
| 4596 |
|
| 4597 |
‘test15’ |
| 4598 |
When removed, this surface produces 64509 double bytes, the first |
| 4599 |
having value 0, the second having value 1, and so forth until all |
| 4600 |
values have been generated, but excluding risky ‘UCS-2’ values, |
| 4601 |
like all codes from the surrogate ‘UCS-2’ area (for ‘UTF-16’), the |
| 4602 |
byte order mark, and values known as invalid ‘UCS-2’. |
| 4603 |
|
| 4604 |
‘test16’ |
| 4605 |
When removed, this surface produces 65536 double bytes, the first |
| 4606 |
having value 0, the second having value 1, and so forth until all |
| 4607 |
65536 values have been generated. |
| 4608 |
|
| 4609 |
As an example, the command ‘recode l5/test8..dump < /dev/null’ is a |
| 4610 |
convoluted way to produce an output similar to ‘recode -lf l5’. It says |
| 4611 |
to generate all possible 256 bytes and interpret them as ‘ISO-8859-9’ |
| 4612 |
codes, while converting them to ‘UCS-2’. Resulting ‘UCS-2’ characters |
| 4613 |
are dumped one per line, accompanied with their explicative name. |
| 4614 |
|
| 4615 |
|
| 4616 |
File: recode.info, Node: Internals, Next: Concept Index, Prev: Surfaces, Up: Top |
| 4617 |
|
| 4618 |
14 Internal aspects |
| 4619 |
******************* |
| 4620 |
|
| 4621 |
The incoming explanations of the internals of Recode should help people |
| 4622 |
who want to dive into Recode sources for adding new charsets. Adding |
| 4623 |
new charsets does not require much knowledge about the overall |
| 4624 |
organisation of Recode. You can rather concentrate of your new charset, |
| 4625 |
letting the remainder of the Recode mechanics take care of |
| 4626 |
interconnecting it with all others charsets. |
| 4627 |
|
| 4628 |
If you intend to play seriously at modifying Recode, beware that you |
| 4629 |
may need some other GNU tools which were not required when you first |
| 4630 |
installed Recode. If you modify or create any ‘.l’ file, then you need |
| 4631 |
Flex, and some better ‘awk’ like ‘mawk’, GNU ‘awk’, or ‘nawk’. If you |
| 4632 |
modify the documentation (and you should!), you need ‘makeinfo’. If you |
| 4633 |
are really audacious, you may also want Perl for modifying tabular |
| 4634 |
processing, then ‘m4’, Autoconf, Automake and ‘libtool’ for adjusting |
| 4635 |
configuration matters. |
| 4636 |
|
| 4637 |
* Menu: |
| 4638 |
|
| 4639 |
* Main flow:: Overall organisation |
| 4640 |
* New charsets:: Adding new charsets |
| 4641 |
* New surfaces:: Adding new surfaces |
| 4642 |
* Design:: Comments on the library design |
| 4643 |
|
| 4644 |
|
| 4645 |
File: recode.info, Node: Main flow, Next: New charsets, Prev: Internals, Up: Internals |
| 4646 |
|
| 4647 |
14.1 Overall organisation |
| 4648 |
========================= |
| 4649 |
|
| 4650 |
The Recode mechanics slowly evolved for many years, and it would be |
| 4651 |
tedious to explain all problems I met and mistakes I did all along, |
| 4652 |
yielding the current behaviour. Surely, one of the key choices was to |
| 4653 |
stop trying to do all conversions in memory, one line or one buffer at a |
| 4654 |
time. It has been fruitful to use the character stream paradigm, and |
| 4655 |
the elementary recoding steps now convert a whole stream to another. |
| 4656 |
Most of the control complexity in Recode exists so that each elementary |
| 4657 |
recoding step stays simple, making easier to add new ones. The whole |
| 4658 |
point of Recode, as I see it, is providing a comfortable nest for |
| 4659 |
growing new charset conversions. |
| 4660 |
|
| 4661 |
The main Recode driver constructs, while initialising all conversion |
| 4662 |
modules, a table giving all the conversion routines available (“single |
| 4663 |
step”s) and for each, the starting charset and the ending charset. If |
| 4664 |
we consider these charsets as being the nodes of a directed graph, each |
| 4665 |
single step may be considered as oriented arc from one node to the |
| 4666 |
other. A cost is attributed to each arc: for example, a high penalty is |
| 4667 |
given to single steps which are prone to losing characters, a lower |
| 4668 |
penalty is given to those which need studying more than one input |
| 4669 |
character for producing an output character, etc. |
| 4670 |
|
| 4671 |
Given a starting code and a goal code, Recode computes the most |
| 4672 |
economical route through the elementary recodings, that is, the best |
| 4673 |
sequence of conversions that will transform the input charset into the |
| 4674 |
final charset. To speed up execution, Recode looks for subsequences of |
| 4675 |
conversions which are simple enough to be merged, and then dynamically |
| 4676 |
creates new single steps to represent these mergings. |
| 4677 |
|
| 4678 |
A “double step” in Recode is a special concept representing a |
| 4679 |
sequence of two single steps, the output of the first single step being |
| 4680 |
the special charset ‘UCS-2’, the input of the second single step being |
| 4681 |
also ‘UCS-2’. Special Recode machinery dynamically produces efficient, |
| 4682 |
reversible, merge-able single steps out of these double steps. |
| 4683 |
|
| 4684 |
I made some statistics about how many internal recoding steps are |
| 4685 |
required between any two charsets chosen at random. The initial |
| 4686 |
recoding layout, before optimisation, always uses between 1 and 5 steps. |
| 4687 |
Optimisation could sometimes produce mere copies, which are counted as |
| 4688 |
no steps at all. In other cases, optimisation is unable to save any |
| 4689 |
step. The number of steps after optimisation is currently between 0 and |
| 4690 |
5 steps. Of course, the _expected_ number of steps is affected by |
| 4691 |
optimisation: it drops from 2.8 to 1.8. This means that Recode uses a |
| 4692 |
theoretical average of a bit less than one step per recoding job. This |
| 4693 |
looks good. This was computed using reversible recodings. In strict |
| 4694 |
mode, optimisation might be defeated somewhat. Number of steps run |
| 4695 |
between 1 and 6, both before and after optimisation, and the expected |
| 4696 |
number of steps decreases by a lesser amount, going from 2.2 to 1.3. |
| 4697 |
This is still manageable. |
| 4698 |
|
| 4699 |
|
| 4700 |
File: recode.info, Node: New charsets, Next: New surfaces, Prev: Main flow, Up: Internals |
| 4701 |
|
| 4702 |
14.2 Adding new charsets |
| 4703 |
======================== |
| 4704 |
|
| 4705 |
The main part of Recode is written in C, as are most single steps. A |
| 4706 |
few single steps need to recognise sequences of multiple characters, |
| 4707 |
they are often better written in Flex. It is easy for a programmer to |
| 4708 |
add a new charset to Recode. All it requires is making a few functions |
| 4709 |
kept in a single ‘.c’ file, adjusting ‘Makefile.am’ and remaking Recode. |
| 4710 |
|
| 4711 |
One of the function should convert from any previous charset to the |
| 4712 |
new one. Any previous charset will do, but try to select it so you will |
| 4713 |
not lose too much information while converting. The other function |
| 4714 |
should convert from the new charset to any older one. You do not have |
| 4715 |
to select the same old charset than what you selected for the previous |
| 4716 |
routine. Once again, select any charset for which you will not lose too |
| 4717 |
much information while converting. |
| 4718 |
|
| 4719 |
If, for any of these two functions, you have to read multiple bytes |
| 4720 |
of the old charset before recognising the character to produce, you |
| 4721 |
might prefer programming it in Flex in a separate ‘.l’ file. Prototype |
| 4722 |
your C or Flex files after one of those which exist already, so to keep |
| 4723 |
the sources uniform. Besides, at ‘make’ time, all ‘.l’ files are |
| 4724 |
automatically merged into a single big one by the script ‘mergelex.awk’. |
| 4725 |
|
| 4726 |
There are a few hidden rules about how to write new Recode modules, |
| 4727 |
for allowing the automatic creation of ‘decsteps.h’ and ‘initsteps.h’ at |
| 4728 |
‘make’ time, or the proper merging of all Flex files. Mimetism is a |
| 4729 |
simple approach which relieves me of explaining all these rules! Start |
| 4730 |
with a module closely resembling what you intend to do. Here is some |
| 4731 |
advice for picking up a model. First decide if your new charset module |
| 4732 |
is to be be driven by algorithms rather than by tables. For algorithmic |
| 4733 |
recodings, see ‘iconqnx.c’ for C code, or ‘txtelat1.l’ for Flex code. |
| 4734 |
For table driven recodings, see ‘ebcdic.c’ for one-to-one style |
| 4735 |
recodings, ‘lat1html.c’ for one-to-many style recodings, or ‘atarist.c’ |
| 4736 |
for double-step style recodings. Just select an example from the style |
| 4737 |
that better fits your application. |
| 4738 |
|
| 4739 |
Each of your source files should have its own initialisation |
| 4740 |
function, named ‘module_CHARSET’, which is meant to be executed |
| 4741 |
_quickly_ once, prior to any recoding. It should declare the name of |
| 4742 |
your charsets and the single steps (or elementary recodings) you |
| 4743 |
provide, by calling ‘declare_step’ one or more times. Besides the |
| 4744 |
charset names, ‘declare_step’ expects a description of the recoding |
| 4745 |
quality (see ‘recodext.h’) and two functions you also provide. |
| 4746 |
|
| 4747 |
The first such function has the purpose of allocating structures, |
| 4748 |
pre-conditioning conversion tables, etc. It is also the way of further |
| 4749 |
modifying the ‘STEP’ structure. This function is executed if and only |
| 4750 |
if the single step is retained in an actual recoding sequence. If you |
| 4751 |
do not need such delayed initialisation, merely use ‘NULL’ for the |
| 4752 |
function argument. |
| 4753 |
|
| 4754 |
The second function executes the elementary recoding on a whole file. |
| 4755 |
|
| 4756 |
If you have a recoding table handy in a suitable format but do not |
| 4757 |
use one of the predefined recoding functions, it is still a good idea to |
| 4758 |
use a delayed initialisation to save it anyway, because ‘recode’ option |
| 4759 |
‘-h’ will take advantage of this information when available. |
| 4760 |
|
| 4761 |
Finally, edit ‘Makefile.am’ to add the source file name of your |
| 4762 |
routines to the ‘C_STEPS’ or ‘L_STEPS’ macro definition, depending on |
| 4763 |
whether your routines are written in C or Flex. |
| 4764 |
|
| 4765 |
|
| 4766 |
File: recode.info, Node: New surfaces, Next: Design, Prev: New charsets, Up: Internals |
| 4767 |
|
| 4768 |
14.3 Adding new surfaces |
| 4769 |
======================== |
| 4770 |
|
| 4771 |
Adding a new surface is technically quite similar to adding a new |
| 4772 |
charset. *Note New charsets::. A surface is provided as a set of two |
| 4773 |
transformations: one from the predefined special charset ‘data’ to the |
| 4774 |
new surface, meant to apply the surface, the other from the new surface |
| 4775 |
to the predefined special charset ‘data’, meant to remove the surface. |
| 4776 |
|
| 4777 |
Internally in Recode, function ‘declare_step’ especially recognises |
| 4778 |
when a charset is so related to ‘data’, and then takes appropriate |
| 4779 |
actions so that charset gets indeed installed as a surface. |
| 4780 |
|
| 4781 |
|
| 4782 |
File: recode.info, Node: Design, Prev: New surfaces, Up: Internals |
| 4783 |
|
| 4784 |
14.4 Comments on the library design |
| 4785 |
=================================== |
| 4786 |
|
| 4787 |
• Why a shared library? |
| 4788 |
|
| 4789 |
There are many different approaches to reduce system requirements |
| 4790 |
to handle all tables needed in the Recode library. One of them is |
| 4791 |
to have the tables in an external format and only read them in on |
| 4792 |
demand. After having pondered this for a while, I finally decided |
| 4793 |
against it, mainly because it involves its own kind of installation |
| 4794 |
complexity, and it is not clear to me that it would be as |
| 4795 |
interesting as I first imagined. |
| 4796 |
|
| 4797 |
It looks more efficient to see all tables and algorithms already |
| 4798 |
mapped into virtual memory from the start of the execution, yet not |
| 4799 |
loaded in actual memory, than to go through many disk accesses for |
| 4800 |
opening various data files once the program is already started, as |
| 4801 |
this would be needed with other solutions. Using a shared library |
| 4802 |
also has the indirect effect of making various algorithms handily |
| 4803 |
available, right in the same modules providing the tables. This |
| 4804 |
alleviates much the burden of the maintenance. |
| 4805 |
|
| 4806 |
Of course, I would like to later make an exception for only a few |
| 4807 |
tables, built locally by users for their own particular needs once |
| 4808 |
Recode is installed. Recode should just go and fetch them. But I |
| 4809 |
do not perceive this as very urgent, yet useful enough to be worth |
| 4810 |
implementing. |
| 4811 |
|
| 4812 |
Currently, all tables needed for recoding are precompiled into |
| 4813 |
binaries, and all these binaries are then made into a shared |
| 4814 |
library. As an initial step, I turned Recode into a main program |
| 4815 |
and a non-shared library, this allowed me to tidy up the API, get |
| 4816 |
rid of all global variables, etc. It required a surprising amount |
| 4817 |
of program source massaging. But once this cleaned enough, it was |
| 4818 |
easy to use Gordon Matzigkeit's ‘libtool’ package, and take |
| 4819 |
advantage of the Automake interface to neatly turn the non-shared |
| 4820 |
library into a shared one. |
| 4821 |
|
| 4822 |
Sites linking with the Recode library, whose system does not |
| 4823 |
support any form of shared libraries, might end up with bulky |
| 4824 |
executables. Surely, the Recode library will have to be used |
| 4825 |
statically, and might not very nicely usable on such systems. It |
| 4826 |
seems that progress has a price for those being slow at it. |
| 4827 |
|
| 4828 |
There is a locality problem I did not address yet. Currently, the |
| 4829 |
Recode library takes many cycles to initialise itself, calling each |
| 4830 |
module in turn for it to set up associated knowledge about |
| 4831 |
charsets, aliases, elementary steps, recoding weights, etc. |
| 4832 |
_Then_, the recoding sequence is decided out of the command given. |
| 4833 |
One thing to do would have Recode to pre-load all tables and dump |
| 4834 |
them at installation time. The result would then be compiled and |
| 4835 |
added to the library. This would spare many initialisation cycles, |
| 4836 |
but more importantly, would avoid calling all library modules, |
| 4837 |
scattered through the virtual memory, and so, possibly causing many |
| 4838 |
spurious page exceptions each time the initialisation is requested, |
| 4839 |
at least once per program execution. |
| 4840 |
|
| 4841 |
• Why not a central charset? |
| 4842 |
|
| 4843 |
It would be simpler, and I would like, if something like ISO 10646 |
| 4844 |
was used as a turning template for all charsets in Recode. Even if |
| 4845 |
I think it could help to a certain extent, I'm still not fully sure |
| 4846 |
it would be sufficient in all cases. Moreover, some people |
| 4847 |
disagree about using ISO 10646 as the central charset, to the point |
| 4848 |
I cannot totally ignore them, and surely, Recode is not a means for |
| 4849 |
me to force my own opinions on people. I would like that Recode be |
| 4850 |
practical more than dogmatic, and reflect usage more than |
| 4851 |
religions. |
| 4852 |
|
| 4853 |
Currently, if you ask Recode to go from CHARSET1 to CHARSET2 chosen |
| 4854 |
at random, it is highly probable that the best path will be quickly |
| 4855 |
found as: |
| 4856 |
|
| 4857 |
CHARSET1..UCS-2..CHARSET2 |
| 4858 |
|
| 4859 |
That is, it will almost always use the ‘UCS’ as a trampoline |
| 4860 |
between charsets. However, ‘UCS-2’ will be immediately be |
| 4861 |
optimised out, and CHARSET1..CHARSET2 will often be performed in a |
| 4862 |
single step through a permutation table generated on the fly for |
| 4863 |
the circumstance (1). |
| 4864 |
|
| 4865 |
In those few cases where ‘UCS-2’ is not selected as a conceptual |
| 4866 |
intermediate, I plan to study if it could be made so. But I guess |
| 4867 |
some cases will remain where ‘UCS-2’ is not a proper choice. Even |
| 4868 |
if ‘UCS’ is often the good choice, I do not intend to forcefully |
| 4869 |
restrain Recode around ‘UCS-2’ (nor ‘UCS-4’) for now. We might |
| 4870 |
come to that one day, but it will come out of the natural evolution |
| 4871 |
of Recode. It will then reflect a fact, rather than a preset |
| 4872 |
dogma. |
| 4873 |
|
| 4874 |
• Why not ‘iconv’? |
| 4875 |
|
| 4876 |
The ‘iconv’ routine and library allows for converting characters |
| 4877 |
from an input buffer to an input buffer, synchronously advancing |
| 4878 |
both buffer cursors. If the output buffer is not big enough to |
| 4879 |
receive all of the conversion, the routine returns with the input |
| 4880 |
cursor set at the position where the conversion could later be |
| 4881 |
resumed, and the output cursor set to indicate until where the |
| 4882 |
output buffer has been filled. Despite this scheme is simple and |
| 4883 |
nice, the Recode library does not offer it currently. Why not? |
| 4884 |
|
| 4885 |
When long sequences of decodings, stepwise recodings, and |
| 4886 |
re-encodings are involved, as it happens in true life, |
| 4887 |
synchronising the input buffer back to where it should have |
| 4888 |
stopped, when the output buffer becomes full, is a difficult |
| 4889 |
problem. Oh, we could make it simpler at the expense of losing |
| 4890 |
space or speed: by inserting markers between each input character |
| 4891 |
and counting them at the output end; by processing only one |
| 4892 |
character in a time through the whole sequence; by repeatedly |
| 4893 |
attempting to recode various subsets of the input buffer, binary |
| 4894 |
searching on their length until the output just fits. The overhead |
| 4895 |
of such solutions looks prohibitive to me, and the gain very |
| 4896 |
minimal. I do not see a real advantage, nowadays, imposing a fixed |
| 4897 |
length to an output buffer. It makes things so much simpler and |
| 4898 |
efficient to just let the output buffer size float a bit. |
| 4899 |
|
| 4900 |
Of course, if the above problem was solved, the ‘iconv’ library |
| 4901 |
should be easily emulated, given that Recode has similar knowledge |
| 4902 |
about charsets, of course. This either solved or not, the ‘iconv’ |
| 4903 |
program remains trivial (given similar knowledge about charsets). |
| 4904 |
I also presume that the ‘genxlt’ program would be easy too, but I |
| 4905 |
do not have enough detailed specifications of it to be sure. |
| 4906 |
|
| 4907 |
A lot of years ago, Recode was using a similar scheme, and I found |
| 4908 |
it rather hard to manage for some cases. I rethought the overall |
| 4909 |
structure of Recode for getting away from that scheme, and never |
| 4910 |
regretted it. I perceive ‘iconv’ as an artificial solution which |
| 4911 |
surely has some elegances and virtues, but I do not find it really |
| 4912 |
useful as it stands: one always has to wrap ‘iconv’ into something |
| 4913 |
more refined, extending it for real cases. From past experience, I |
| 4914 |
think it is unduly hard to fully implement this scheme. It would |
| 4915 |
be awkward that we do contortions for the sole purpose of |
| 4916 |
implementing exactly its specification, without real, properly |
| 4917 |
grounded reasons (other then the fact some people once thought it |
| 4918 |
was worth standardising). It is much better to immediately aim for |
| 4919 |
the refinement we need, without uselessly forcing us into the |
| 4920 |
dubious detour ‘iconv’ represents. |
| 4921 |
|
| 4922 |
Some may argue that if Recode was using a comprehensive charset as |
| 4923 |
a turning template, as discussed in a previous point, this would |
| 4924 |
make ‘iconv’ easier to implement. Some may be tempted to say that |
| 4925 |
the cases which are hard to handle are not really needed, nor |
| 4926 |
interesting, anyway. I feel and fear a bit some pressure wanting |
| 4927 |
that Recode be split into the part that well fits the ‘iconv’ |
| 4928 |
model, and the part that does not fit, considering this second part |
| 4929 |
less important, with the idea of dropping it one of these days, |
| 4930 |
maybe. My guess is that users of the Recode library, whatever its |
| 4931 |
form, would not like to have such arbitrary limitations. In the |
| 4932 |
long run, we should not have to explain to our users that some |
| 4933 |
recodings may not be made available just because they do not fit |
| 4934 |
the simple model we had in mind when we did it. Instead, we should |
| 4935 |
try to stay open to the difficulties of real life. There is still |
| 4936 |
a lot of complex needs for Asian people, say, that Recode does not |
| 4937 |
currently address, while it should. Not only the doors should stay |
| 4938 |
open, but we should force them wider! |
| 4939 |
|
| 4940 |
---------- Footnotes ---------- |
| 4941 |
|
| 4942 |
(1) If strict mapping is requested, another efficient device will be |
| 4943 |
used instead of a permutation. |
| 4944 |
|
| 4945 |
|
| 4946 |
File: recode.info, Node: Concept Index, Next: Option Index, Prev: Internals, Up: Top |
| 4947 |
|
| 4948 |
Concept Index |
| 4949 |
************* |
| 4950 |
|
| 4951 |
|