Debian Codegraph @

texmf-dist/omega/otp/uni2char/oututf8.otp

raw
1 % File oututf8.otp
2 % Conversion to UTF-8 from UTF-16
3 % Copyright (c) 1999 John Plaice and Yannis Haralambous
4 % Copyright (C) 2005, 2006 Roozbeh Pournader
5 % This file is part of the Omega project.
6 %
7
8 input: 2;
9 output: 1;
10
11 expressions:
12
13 % One-byte sequences get mapped to proper ASCII
14 @"0000-@"007F
15 => \1;
16
17 % Two-byte sequences
18 @"0080-@"07FF
19 => #((\1 div: @"40)+@"C0)
20 #((\1 mod: @"40)+@"80);
21
22 % Three-byte sequences
23 (@"0800-@"D7FF|@"E000-@"FFFF)
24 => #((\1 div: @"1000)+@"E0)
25 #(((\1 mod: @"1000) div: @"40)+@"80)
26 #((\1 mod: @"40)+@"80);
27
28 % Surrogate pairs, which make four-byte sequences:
29 (@"D800-@"DBFF)(@"DC00-@"DFFF)
30 => #(((((\1 mod: @"400) div: 4)+@"10) div: @"40)+@"F0)
31 #(((((\1 mod: @"400) div: 4)+@"10) mod: @"40)+@"80)
32 #(((\1 mod: 4)*@"10) +((\2 mod: @"400) div: @"40)+@"80)
33 #((\2 mod: @"40)+@"80);
34
35 % Anything else gets mapped to 0x00. This should probably
36 % get replaced by an error message, instead.
37 . => #(@"00);