📄 perlebcdic.pod
字号:
<C1 7> 135 23 23 23 <C1 8> 136 40 40 40 <C1 9> 137 41 41 41 <C1 10> 138 42 42 42 <C1 11> 139 43 43 43 <C1 12> 140 44 44 44 <C1 13> 141 9 9 9 <C1 14> 142 10 10 10 <C1 15> 143 27 27 27 <C1 16> 144 48 48 48 <C1 17> 145 49 49 49 <C1 18> 146 26 26 26 <C1 19> 147 51 51 51 <C1 20> 148 52 52 52 <C1 21> 149 53 53 53 <C1 22> 150 54 54 54 <C1 23> 151 8 8 8 <C1 24> 152 56 56 56 <C1 25> 153 57 57 57 <C1 26> 154 58 58 58 <C1 27> 155 59 59 59 <C1 28> 156 4 4 4 <C1 29> 157 20 20 20 <C1 30> 158 62 62 62 <C1 31> 159 255 255 95 ### <NON-BREAKING SPACE> 160 65 65 65 <INVERTED EXCLAMATION MARK> 161 170 170 170 <CENT SIGN> 162 74 74 176 ### <POUND SIGN> 163 177 177 177 <CURRENCY SIGN> 164 159 159 159 <YEN SIGN> 165 178 178 178 <BROKEN BAR> 166 106 106 208 ### <SECTION SIGN> 167 181 181 181 <DIAERESIS> 168 189 187 121 *** ### <COPYRIGHT SIGN> 169 180 180 180 <FEMININE ORDINAL INDICATOR> 170 154 154 154 <LEFT POINTING GUILLEMET> 171 138 138 138 <NOT SIGN> 172 95 176 186 *** ### <SOFT HYPHEN> 173 202 202 202 <REGISTERED TRADE MARK SIGN> 174 175 175 175 <MACRON> 175 188 188 161 ### <DEGREE SIGN> 176 144 144 144 <PLUS-OR-MINUS SIGN> 177 143 143 143 <SUPERSCRIPT TWO> 178 234 234 234 <SUPERSCRIPT THREE> 179 250 250 250 <ACUTE ACCENT> 180 190 190 190 <MICRO SIGN> 181 160 160 160 <PARAGRAPH SIGN> 182 182 182 182 <MIDDLE DOT> 183 179 179 179 <CEDILLA> 184 157 157 157 <SUPERSCRIPT ONE> 185 218 218 218 <MASC. ORDINAL INDICATOR> 186 155 155 155 <RIGHT POINTING GUILLEMET> 187 139 139 139 <FRACTION ONE QUARTER> 188 183 183 183 <FRACTION ONE HALF> 189 184 184 184 <FRACTION THREE QUARTERS> 190 185 185 185 <INVERTED QUESTION MARK> 191 171 171 171 <A WITH GRAVE> 192 100 100 100 <A WITH ACUTE> 193 101 101 101 <A WITH CIRCUMFLEX> 194 98 98 98 <A WITH TILDE> 195 102 102 102 <A WITH DIAERESIS> 196 99 99 99 <A WITH RING ABOVE> 197 103 103 103 <CAPITAL LIGATURE AE> 198 158 158 158 <C WITH CEDILLA> 199 104 104 104 <E WITH GRAVE> 200 116 116 116 <E WITH ACUTE> 201 113 113 113 <E WITH CIRCUMFLEX> 202 114 114 114 <E WITH DIAERESIS> 203 115 115 115 <I WITH GRAVE> 204 120 120 120 <I WITH ACUTE> 205 117 117 117 <I WITH CIRCUMFLEX> 206 118 118 118 <I WITH DIAERESIS> 207 119 119 119 <CAPITAL LETTER ETH> 208 172 172 172 <N WITH TILDE> 209 105 105 105 <O WITH GRAVE> 210 237 237 237 <O WITH ACUTE> 211 238 238 238 <O WITH CIRCUMFLEX> 212 235 235 235 <O WITH TILDE> 213 239 239 239 <O WITH DIAERESIS> 214 236 236 236 <MULTIPLICATION SIGN> 215 191 191 191 <O WITH STROKE> 216 128 128 128 <U WITH GRAVE> 217 253 253 224 ### <U WITH ACUTE> 218 254 254 254 <U WITH CIRCUMFLEX> 219 251 251 221 ### <U WITH DIAERESIS> 220 252 252 252 <Y WITH ACUTE> 221 173 186 173 *** ### <CAPITAL LETTER THORN> 222 174 174 174 <SMALL LETTER SHARP S> 223 89 89 89 <a WITH GRAVE> 224 68 68 68 <a WITH ACUTE> 225 69 69 69 <a WITH CIRCUMFLEX> 226 66 66 66 <a WITH TILDE> 227 70 70 70 <a WITH DIAERESIS> 228 67 67 67 <a WITH RING ABOVE> 229 71 71 71 <SMALL LIGATURE ae> 230 156 156 156 <c WITH CEDILLA> 231 72 72 72 <e WITH GRAVE> 232 84 84 84 <e WITH ACUTE> 233 81 81 81 <e WITH CIRCUMFLEX> 234 82 82 82 <e WITH DIAERESIS> 235 83 83 83 <i WITH GRAVE> 236 88 88 88 <i WITH ACUTE> 237 85 85 85 <i WITH CIRCUMFLEX> 238 86 86 86 <i WITH DIAERESIS> 239 87 87 87 <SMALL LETTER eth> 240 140 140 140 <n WITH TILDE> 241 73 73 73 <o WITH GRAVE> 242 205 205 205 <o WITH ACUTE> 243 206 206 206 <o WITH CIRCUMFLEX> 244 203 203 203 <o WITH TILDE> 245 207 207 207 <o WITH DIAERESIS> 246 204 204 204 <DIVISION SIGN> 247 225 225 225 <o WITH STROKE> 248 112 112 112 <u WITH GRAVE> 249 221 221 192 ### <u WITH ACUTE> 250 222 222 222 <u WITH CIRCUMFLEX> 251 219 219 219 <u WITH DIAERESIS> 252 220 220 220 <y WITH ACUTE> 253 141 141 141 <SMALL LETTER thorn> 254 142 142 142 <y WITH DIAERESIS> 255 223 223 223If you would rather see the above table in CCSID 0037 order rather thanASCII + Latin-1 order then run the table through:=over 4=item recipe 2=back perl -ne 'if(/.{33}\d{1,3}\s{6,8}\d{1,3}\s{6,8}\d{1,3}\s{6,8}\d{1,3}/)'\ -e '{push(@l,$_)}' \ -e 'END{print map{$_->[0]}' \ -e ' sort{$a->[1] <=> $b->[1]}' \ -e ' map{[$_,substr($_,42,3)]}@l;}' perlebcdic.podIf you would rather see it in CCSID 1047 order then change the digit42 in the last line to 51, like this:=over 4=item recipe 3=back perl -ne 'if(/.{33}\d{1,3}\s{6,8}\d{1,3}\s{6,8}\d{1,3}\s{6,8}\d{1,3}/)'\ -e '{push(@l,$_)}' \ -e 'END{print map{$_->[0]}' \ -e ' sort{$a->[1] <=> $b->[1]}' \ -e ' map{[$_,substr($_,51,3)]}@l;}' perlebcdic.podIf you would rather see it in POSIX-BC order then change the digit51 in the last line to 60, like this:=over 4=item recipe 4=back perl -ne 'if(/.{33}\d{1,3}\s{6,8}\d{1,3}\s{6,8}\d{1,3}\s{6,8}\d{1,3}/)'\ -e '{push(@l,$_)}' \ -e 'END{print map{$_->[0]}' \ -e ' sort{$a->[1] <=> $b->[1]}' \ -e ' map{[$_,substr($_,60,3)]}@l;}' perlebcdic.pod=head1 IDENTIFYING CHARACTER CODE SETSTo determine the character set you are running under from perl one could use the return value of ord() or chr() to test one or more character values. For example: $is_ascii = "A" eq chr(65); $is_ebcdic = "A" eq chr(193);Also, "\t" is a C<HORIZONTAL TABULATION> character so that: $is_ascii = ord("\t") == 9; $is_ebcdic = ord("\t") == 5;To distinguish EBCDIC code pages try looking at one or more ofthe characters that differ between them. For example: $is_ebcdic_37 = "\n" eq chr(37); $is_ebcdic_1047 = "\n" eq chr(21);Or better still choose a character that is uniquely encoded in anyof the code sets, e.g.: $is_ascii = ord('[') == 91; $is_ebcdic_37 = ord('[') == 186; $is_ebcdic_1047 = ord('[') == 173; $is_ebcdic_POSIX_BC = ord('[') == 187;However, it would be unwise to write tests such as: $is_ascii = "\r" ne chr(13); # WRONG $is_ascii = "\n" ne chr(10); # ILL ADVISEDObviously the first of these will fail to distinguish most ASCII machinesfrom either a CCSID 0037, a 1047, or a POSIX-BC EBCDIC machine since "\r" eq chr(13) under all of those coded character sets. But note too that because "\n" is chr(13) and "\r" is chr(10) on the MacIntosh (which is an ASCII machine) the second C<$is_ascii> test will lead to trouble there.To determine whether or not perl was built under an EBCDIC code page you can use the Config module like so: use Config; $is_ebcdic = $Config{'ebcdic'} eq 'define';=head1 CONVERSIONS=head2 tr///In order to convert a string of characters from one character set to another a simple list of numbers, such as in the right columns in theabove table, along with perl's tr/// operator is all that is needed. The data in the table are in ASCII order hence the EBCDIC columns provide easy to use ASCII to EBCDIC operations that are also easily reversed.For example, to convert ASCII to code page 037 take the output of the second column from the output of recipe 0 (modified to add \\ characters) and use it in tr/// like so: $cp_037 = '\000\001\002\003\234\011\206\177\227\215\216\013\014\015\016\017' . '\020\021\022\023\235\205\010\207\030\031\222\217\034\035\036\037' . '\200\201\202\203\204\012\027\033\210\211\212\213\214\005\006\007' . '\220\221\026\223\224\225\226\004\230\231\232\233\024\025\236\032' . '\040\240\342\344\340\341\343\345\347\361\242\056\074\050\053\174' . '\046\351\352\353\350\355\356\357\354\337\041\044\052\051\073\254' . '\055\057\302\304\300\301\303\305\307\321\246\054\045\137\076\077' . '\370\311\312\313\310\315\316\317\314\140\072\043\100\047\075\042' . '\330\141\142\143\144\145\146\147\150\151\253\273\360\375\376\261' . '\260\152\153\154\155\156\157\160\161\162\252\272\346\270\306\244' . '\265\176\163\164\165\166\167\170\171\172\241\277\320\335\336\256' . '\136\243\245\267\251\247\266\274\275\276\133\135\257\250\264\327' . '\173\101\102\103\104\105\106\107\110\111\255\364\366\362\363\365' . '\175\112\113\114\115\116\117\120\121\122\271\373\374\371\372\377' . '\134\367\123\124\125\126\127\130\131\132\262\324\326\322\323\325' . '\060\061\062\063\064\065\066\067\070\071\263\333\334\331\332\237' ; my $ebcdic_string = $ascii_string; eval '$ebcdic_string =~ tr/\000-\377/' . $cp_037 . '/';To convert from EBCDIC 037 to ASCII just reverse the order of the tr/// arguments like so: my $ascii_string = $ebcdic_string; eval '$ascii_string = tr/' . $cp_037 . '/\000-\377/';Similarly one could take the output of the third column from recipe 0 toobtain a C<$cp_1047> table. The fourth column of the output from recipe0 could provide a C<$cp_posix_bc> table suitable for transcoding as well.=head2 iconvXPG operability often implies the presence of an I<iconv> utilityavailable from the shell or from the C library. Consult your system'sdocumentation for information on iconv.On OS/390 see the iconv(1) man page. One way to invoke the iconv shell utility from within perl would be to: # OS/390 example $ascii_data = `echo '$ebcdic_data'| iconv -f IBM-1047 -t ISO8859-1`or the inverse map: # OS/390 example $ebcdic_data = `echo '$ascii_data'| iconv -f ISO8859-1 -t IBM-1047`For other perl based conversion options see the Convert::* modules on CPAN.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -