{ ***************************************************************************** * * * This file is part of the Lazarus Component Library (LCL) * * * * See the file COPYING.modifiedLGPL, included in this distribution, * * for details about the copyright. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * * ***************************************************************************** } unit LConvEncoding; {$mode objfpc}{$H+} //As iconv is Linux command, there is no sense in Windows {$IFDEF MSWindows} {$DEFINE WINDOWS} {$ENDIF} {$IFDEF WINDOWS} {$WARNING Windows/Wine/ReactOS locale conversion is not fully supported yet. Sorry.} {$ENDIF} interface uses SysUtils, Classes, dos, LCLProc {$IFDEF UNIX},unix{$ENDIF}; {$inline on} const EncodingUTF8 = 'utf8'; EncodingAnsi = 'ansi'; function GuessEncoding(const s: string): string; function ConvertEncoding(const s, FromEncoding, ToEncoding: string): string; function GetSystemEncoding: string; function NormalizeEncoding(const Encoding: string): string; type TConvertEncodingFunction = function(const s: string): string; TCharToUTF8Table = array[char] of PChar; TUnicodeToCharID = function(Unicode: cardinal): integer; var ConvertAnsiToUTF8: TConvertEncodingFunction = nil; ConvertUTF8ToAnsi: TConvertEncodingFunction = nil; function ISO_8859_1ToUTF8(const s: string): string; // central europe function CP1250ToUTF8(const s: string): string; // central europe function CP1251ToUTF8(const s: string): string; // cyrillic function CP1252ToUTF8(const s: string): string; // latin 1 function CP1253ToUTF8(const s: string): string; // greek function CP1254ToUTF8(const s: string): string; // turkish function CP1255ToUTF8(const s: string): string; // hebrew function CP1256ToUTF8(const s: string): string; // arabic function CP1257ToUTF8(const s: string): string; // baltic function CP1258ToUTF8(const s: string): string; // vietnam function CP874ToUTF8(const s: string): string; // thai function KOI8ToUTF8(const s: string): string; // russian cyrillic function SingleByteToUTF8(const s: string; const Table: TCharToUTF8Table): string; function UTF8ToISO_8859_1(const s: string): string; // central europe function UTF8ToCP1250(const s: string): string; // central europe function UTF8ToCP1251(const s: string): string; // cyrillic function UTF8ToCP1252(const s: string): string; // latin 1 function UTF8ToCP1253(const s: string): string; // greek function UTF8ToCP1254(const s: string): string; // turkish function UTF8ToCP1255(const s: string): string; // hebrew function UTF8ToCP1256(const s: string): string; // arabic function UTF8ToCP1257(const s: string): string; // baltic function UTF8ToCP1258(const s: string): string; // vietnam function UTF8ToCP874(const s: string): string; // thai function UTF8ToKOI8(const s: string): string; // russian cyrillic function UTF8ToSingleByte(const s: string; const UTF8CharConvFunc: TUnicodeToCharID): string; procedure GetSupportedEncodings(List: TStrings); implementation var EncodingValid: boolean = false; SystemEncoding: string = EncodingAnsi; function GetSystemEncoding: string; var Lang: string; i: integer; s: string; begin if EncodingValid then begin Result:=SystemEncoding; exit; end; Result:=EncodingAnsi; lang := GetEnv('LC_ALL'); if Length(lang) = 0 then begin lang := GetEnv('LC_MESSAGES'); if Length(lang) = 0 then begin lang := GetEnv('LANG'); end; end; i:=pos('.',Lang); if (i>0) and (i<=length(Lang)) then Result:=copy(Lang,i+1,length(Lang)-i); // check parameters for i:=1 to ParamCount do begin s:=ParamStr(i); if s='--charset=' then Result:=copy(s,pos(#61,s),length(s)); end; Result:=NormalizeEncoding(Result); SystemEncoding:=Result; EncodingValid:=true; end; function NormalizeEncoding(const Encoding: string): string; var i: Integer; begin Result:=LowerCase(Encoding); for i:=length(Result) downto 1 do if Result[i]='-' then System.Delete(Result,i,1); end; const ArrayISO_8859_1ToUTF8: TCharToUTF8Table = ( #0, // #0 #1, // #1 #2, // #2 #3, // #3 #4, // #4 #5, // #5 #6, // #6 #7, // #7 #8, // #8 #9, // #9 #10, // #10 #11, // #11 #12, // #12 #13, // #13 #14, // #14 #15, // #15 #16, // #16 #17, // #17 #18, // #18 #19, // #19 #20, // #20 #21, // #21 #22, // #22 #23, // #23 #24, // #24 #25, // #25 #26, // #26 #27, // #27 #28, // #28 #29, // #29 #30, // #30 #31, // #31 ' ', // ' ' '!', // '!' '"', // '"' '#', // '#' '$', // '$' '%', // '%' '&', // '&' '''', // '''' '(', // '(' ')', // ')' '*', // '*' '+', // '+' ',', // ',' '-', // '-' '.', // '.' '/', // '/' '0', // '0' '1', // '1' '2', // '2' '3', // '3' '4', // '4' '5', // '5' '6', // '6' '7', // '7' '8', // '8' '9', // '9' ':', // ':' ';', // ';' '<', // '<' '=', // '=' '>', // '>' '?', // '?' '@', // '@' 'A', // 'A' 'B', // 'B' 'C', // 'C' 'D', // 'D' 'E', // 'E' 'F', // 'F' 'G', // 'G' 'H', // 'H' 'I', // 'I' 'J', // 'J' 'K', // 'K' 'L', // 'L' 'M', // 'M' 'N', // 'N' 'O', // 'O' 'P', // 'P' 'Q', // 'Q' 'R', // 'R' 'S', // 'S' 'T', // 'T' 'U', // 'U' 'V', // 'V' 'W', // 'W' 'X', // 'X' 'Y', // 'Y' 'Z', // 'Z' '[', // '[' '\', // '\' ']', // ']' '^', // '^' '_', // '_' '`', // '`' 'a', // 'a' 'b', // 'b' 'c', // 'c' 'd', // 'd' 'e', // 'e' 'f', // 'f' 'g', // 'g' 'h', // 'h' 'i', // 'i' 'j', // 'j' 'k', // 'k' 'l', // 'l' 'm', // 'm' 'n', // 'n' 'o', // 'o' 'p', // 'p' 'q', // 'q' 'r', // 'r' 's', // 's' 't', // 't' 'u', // 'u' 'v', // 'v' 'w', // 'w' 'x', // 'x' 'y', // 'y' 'z', // 'z' '{', // '{' '|', // '|' '}', // '}' '~', // '~' #127, // #127 #194#128, // #128 #194#129, // #129 #194#130, // #130 #194#131, // #131 #194#132, // #132 #194#133, // #133 #194#134, // #134 #194#135, // #135 #194#136, // #136 #194#137, // #137 #194#138, // #138 #194#139, // #139 #194#140, // #140 #194#141, // #141 #194#142, // #142 #194#143, // #143 #194#144, // #144 #194#145, // #145 #194#146, // #146 #194#147, // #147 #194#148, // #148 #194#149, // #149 #194#150, // #150 #194#151, // #151 #194#152, // #152 #194#153, // #153 #194#154, // #154 #194#155, // #155 #194#156, // #156 #194#157, // #157 #194#158, // #158 #194#159, // #159 #194#160, // #160 #194#161, // #161 #194#162, // #162 #194#163, // #163 #194#164, // #164 #194#165, // #165 #194#166, // #166 #194#167, // #167 #194#168, // #168 #194#169, // #169 #194#170, // #170 #194#171, // #171 #194#172, // #172 #194#173, // #173 #194#174, // #174 #194#175, // #175 #194#176, // #176 #194#177, // #177 #194#178, // #178 #194#179, // #179 #194#180, // #180 #194#181, // #181 #194#182, // #182 #194#183, // #183 #194#184, // #184 #194#185, // #185 #194#186, // #186 #194#187, // #187 #194#188, // #188 #194#189, // #189 #194#190, // #190 #194#191, // #191 #195#128, // #192 #195#129, // #193 #195#130, // #194 #195#131, // #195 #195#132, // #196 #195#133, // #197 #195#134, // #198 #195#135, // #199 #195#136, // #200 #195#137, // #201 #195#138, // #202 #195#139, // #203 #195#140, // #204 #195#141, // #205 #195#142, // #206 #195#143, // #207 #195#144, // #208 #195#145, // #209 #195#146, // #210 #195#147, // #211 #195#148, // #212 #195#149, // #213 #195#150, // #214 #195#151, // #215 #195#152, // #216 #195#153, // #217 #195#154, // #218 #195#155, // #219 #195#156, // #220 #195#157, // #221 #195#158, // #222 #195#159, // #223 #195#160, // #224 #195#161, // #225 #195#162, // #226 #195#163, // #227 #195#164, // #228 #195#165, // #229 #195#166, // #230 #195#167, // #231 #195#168, // #232 #195#169, // #233 #195#170, // #234 #195#171, // #235 #195#172, // #236 #195#173, // #237 #195#174, // #238 #195#175, // #239 #195#176, // #240 #195#177, // #241 #195#178, // #242 #195#179, // #243 #195#180, // #244 #195#181, // #245 #195#182, // #246 #195#183, // #247 #195#184, // #248 #195#185, // #249 #195#186, // #250 #195#187, // #251 #195#188, // #252 #195#189, // #253 #195#190, // #254 #195#191 // #255 ); ArrayCP1250ToUTF8: TCharToUTF8Table = ( #0, // #0 #1, // #1 #2, // #2 #3, // #3 #4, // #4 #5, // #5 #6, // #6 #7, // #7 #8, // #8 #9, // #9 #10, // #10 #11, // #11 #12, // #12 #13, // #13 #14, // #14 #15, // #15 #16, // #16 #17, // #17 #18, // #18 #19, // #19 #20, // #20 #21, // #21 #22, // #22 #23, // #23 #24, // #24 #25, // #25 #26, // #26 #27, // #27 #28, // #28 #29, // #29 #30, // #30 #31, // #31 ' ', // ' ' '!', // '!' '"', // '"' '#', // '#' '$', // '$' '%', // '%' '&', // '&' '''', // '''' '(', // '(' ')', // ')' '*', // '*' '+', // '+' ',', // ',' '-', // '-' '.', // '.' '/', // '/' '0', // '0' '1', // '1' '2', // '2' '3', // '3' '4', // '4' '5', // '5' '6', // '6' '7', // '7' '8', // '8' '9', // '9' ':', // ':' ';', // ';' '<', // '<' '=', // '=' '>', // '>' '?', // '?' '@', // '@' 'A', // 'A' 'B', // 'B' 'C', // 'C' 'D', // 'D' 'E', // 'E' 'F', // 'F' 'G', // 'G' 'H', // 'H' 'I', // 'I' 'J', // 'J' 'K', // 'K' 'L', // 'L' 'M', // 'M' 'N', // 'N' 'O', // 'O' 'P', // 'P' 'Q', // 'Q' 'R', // 'R' 'S', // 'S' 'T', // 'T' 'U', // 'U' 'V', // 'V' 'W', // 'W' 'X', // 'X' 'Y', // 'Y' 'Z', // 'Z' '[', // '[' '\', // '\' ']', // ']' '^', // '^' '_', // '_' '`', // '`' 'a', // 'a' 'b', // 'b' 'c', // 'c' 'd', // 'd' 'e', // 'e' 'f', // 'f' 'g', // 'g' 'h', // 'h' 'i', // 'i' 'j', // 'j' 'k', // 'k' 'l', // 'l' 'm', // 'm' 'n', // 'n' 'o', // 'o' 'p', // 'p' 'q', // 'q' 'r', // 'r' 's', // 's' 't', // 't' 'u', // 'u' 'v', // 'v' 'w', // 'w' 'x', // 'x' 'y', // 'y' 'z', // 'z' '{', // '{' '|', // '|' '}', // '}' '~', // '~' #127, // #127 #226#130#172, // #128 '', // #129 #226#128#154, // #130 '', // #131 #226#128#158, // #132 #226#128#166, // #133 #226#128#160, // #134 #226#128#161, // #135 '', // #136 #226#128#176, // #137 #197#160, // #138 #226#128#185, // #139 #197#154, // #140 #197#164, // #141 #197#189, // #142 #197#185, // #143 '', // #144 #226#128#152, // #145 #226#128#153, // #146 #226#128#156, // #147 #226#128#157, // #148 #226#128#162, // #149 #226#128#147, // #150 #226#128#148, // #151 '', // #152 #226#132#162, // #153 #197#161, // #154 #226#128#186, // #155 #197#155, // #156 #197#165, // #157 #197#190, // #158 #197#186, // #159 #194#160, // #160 #203#135, // #161 #203#152, // #162 #197#129, // #163 #194#164, // #164 #196#132, // #165 #194#166, // #166 #194#167, // #167 #194#168, // #168 #194#169, // #169 #197#158, // #170 #194#171, // #171 #194#172, // #172 #194#173, // #173 #194#174, // #174 #197#187, // #175 #194#176, // #176 #194#177, // #177 #203#155, // #178 #197#130, // #179 #194#180, // #180 #194#181, // #181 #194#182, // #182 #194#183, // #183 #194#184, // #184 #196#133, // #185 #197#159, // #186 #194#187, // #187 #196#189, // #188 #203#157, // #189 #196#190, // #190 #197#188, // #191 #197#148, // #192 #195#129, // #193 #195#130, // #194 #196#130, // #195 #195#132, // #196 #196#185, // #197 #196#134, // #198 #195#135, // #199 #196#140, // #200 #195#137, // #201 #196#152, // #202 #195#139, // #203 #196#154, // #204 #195#141, // #205 #195#142, // #206 #196#142, // #207 #196#144, // #208 #197#131, // #209 #197#135, // #210 #195#147, // #211 #195#148, // #212 #197#144, // #213 #195#150, // #214 #195#151, // #215 #197#152, // #216 #197#174, // #217 #195#154, // #218 #197#176, // #219 #195#156, // #220 #195#157, // #221 #197#162, // #222 #195#159, // #223 #197#149, // #224 #195#161, // #225 #195#162, // #226 #196#131, // #227 #195#164, // #228 #196#186, // #229 #196#135, // #230 #195#167, // #231 #196#141, // #232 #195#169, // #233 #196#153, // #234 #195#171, // #235 #196#155, // #236 #195#173, // #237 #195#174, // #238 #196#143, // #239 #196#145, // #240 #197#132, // #241 #197#136, // #242 #195#179, // #243 #195#180, // #244 #197#145, // #245 #195#182, // #246 #195#183, // #247 #197#153, // #248 #197#175, // #249 #195#186, // #250 #197#177, // #251 #195#188, // #252 #195#189, // #253 #197#163, // #254 #203#153 // #255 ); ArrayCP1251ToUTF8: TCharToUTF8Table = ( #0, // #0 #1, // #1 #2, // #2 #3, // #3 #4, // #4 #5, // #5 #6, // #6 #7, // #7 #8, // #8 #9, // #9 #10, // #10 #11, // #11 #12, // #12 #13, // #13 #14, // #14 #15, // #15 #16, // #16 #17, // #17 #18, // #18 #19, // #19 #20, // #20 #21, // #21 #22, // #22 #23, // #23 #24, // #24 #25, // #25 #26, // #26 #27, // #27 #28, // #28 #29, // #29 #30, // #30 #31, // #31 ' ', // ' ' '!', // '!' '"', // '"' '#', // '#' '$', // '$' '%', // '%' '&', // '&' '''', // '''' '(', // '(' ')', // ')' '*', // '*' '+', // '+' ',', // ',' '-', // '-' '.', // '.' '/', // '/' '0', // '0' '1', // '1' '2', // '2' '3', // '3' '4', // '4' '5', // '5' '6', // '6' '7', // '7' '8', // '8' '9', // '9' ':', // ':' ';', // ';' '<', // '<' '=', // '=' '>', // '>' '?', // '?' '@', // '@' 'A', // 'A' 'B', // 'B' 'C', // 'C' 'D', // 'D' 'E', // 'E' 'F', // 'F' 'G', // 'G' 'H', // 'H' 'I', // 'I' 'J', // 'J' 'K', // 'K' 'L', // 'L' 'M', // 'M' 'N', // 'N' 'O', // 'O' 'P', // 'P' 'Q', // 'Q' 'R', // 'R' 'S', // 'S' 'T', // 'T' 'U', // 'U' 'V', // 'V' 'W', // 'W' 'X', // 'X' 'Y', // 'Y' 'Z', // 'Z' '[', // '[' '\', // '\' ']', // ']' '^', // '^' '_', // '_' '`', // '`' 'a', // 'a' 'b', // 'b' 'c', // 'c' 'd', // 'd' 'e', // 'e' 'f', // 'f' 'g', // 'g' 'h', // 'h' 'i', // 'i' 'j', // 'j' 'k', // 'k' 'l', // 'l' 'm', // 'm' 'n', // 'n' 'o', // 'o' 'p', // 'p' 'q', // 'q' 'r', // 'r' 's', // 's' 't', // 't' 'u', // 'u' 'v', // 'v' 'w', // 'w' 'x', // 'x' 'y', // 'y' 'z', // 'z' '{', // '{' '|', // '|' '}', // '}' '~', // '~' #127, // #127 #208#130, // #128 #208#131, // #129 #226#128#154, // #130 #209#147, // #131 #226#128#158, // #132 #226#128#166, // #133 #226#128#160, // #134 #226#128#161, // #135 #226#130#172, // #136 #226#128#176, // #137 #208#137, // #138 #226#128#185, // #139 #208#138, // #140 #208#140, // #141 #208#139, // #142 #208#143, // #143 #209#146, // #144 #226#128#152, // #145 #226#128#153, // #146 #226#128#156, // #147 #226#128#157, // #148 #226#128#162, // #149 #226#128#147, // #150 #226#128#148, // #151 '', // #152 #226#132#162, // #153 #209#153, // #154 #226#128#186, // #155 #209#154, // #156 #209#156, // #157 #209#155, // #158 #209#159, // #159 #194#160, // #160 #208#142, // #161 #209#158, // #162 #208#136, // #163 #194#164, // #164 #210#144, // #165 #194#166, // #166 #194#167, // #167 #208#129, // #168 #194#169, // #169 #208#132, // #170 #194#171, // #171 #194#172, // #172 #194#173, // #173 #194#174, // #174 #208#135, // #175 #194#176, // #176 #194#177, // #177 #208#134, // #178 #209#150, // #179 #210#145, // #180 #194#181, // #181 #194#182, // #182 #194#183, // #183 #209#145, // #184 #226#132#150, // #185 #209#148, // #186 #194#187, // #187 #209#152, // #188 #208#133, // #189 #209#149, // #190 #209#151, // #191 #208#144, // #192 #208#145, // #193 #208#146, // #194 #208#147, // #195 #208#148, // #196 #208#149, // #197 #208#150, // #198 #208#151, // #199 #208#152, // #200 #208#153, // #201 #208#154, // #202 #208#155, // #203 #208#156, // #204 #208#157, // #205 #208#158, // #206 #208#159, // #207 #208#160, // #208 #208#161, // #209 #208#162, // #210 #208#163, // #211 #208#164, // #212 #208#165, // #213 #208#166, // #214 #208#167, // #215 #208#168, // #216 #208#169, // #217 #208#170, // #218 #208#171, // #219 #208#172, // #220 #208#173, // #221 #208#174, // #222 #208#175, // #223 #208#176, // #224 #208#177, // #225 #208#178, // #226 #208#179, // #227 #208#180, // #228 #208#181, // #229 #208#182, // #230 #208#183, // #231 #208#184, // #232 #208#185, // #233 #208#186, // #234 #208#187, // #235 #208#188, // #236 #208#189, // #237 #208#190, // #238 #208#191, // #239 #209#128, // #240 #209#129, // #241 #209#130, // #242 #209#131, // #243 #209#132, // #244 #209#133, // #245 #209#134, // #246 #209#135, // #247 #209#136, // #248 #209#137, // #249 #209#138, // #250 #209#139, // #251 #209#140, // #252 #209#141, // #253 #209#142, // #254 #209#143 // #255 ); ArrayCP1252ToUTF8: TCharToUTF8Table = ( #0, // #0 #1, // #1 #2, // #2 #3, // #3 #4, // #4 #5, // #5 #6, // #6 #7, // #7 #8, // #8 #9, // #9 #10, // #10 #11, // #11 #12, // #12 #13, // #13 #14, // #14 #15, // #15 #16, // #16 #17, // #17 #18, // #18 #19, // #19 #20, // #20 #21, // #21 #22, // #22 #23, // #23 #24, // #24 #25, // #25 #26, // #26 #27, // #27 #28, // #28 #29, // #29 #30, // #30 #31, // #31 ' ', // ' ' '!', // '!' '"', // '"' '#', // '#' '$', // '$' '%', // '%' '&', // '&' '''', // '''' '(', // '(' ')', // ')' '*', // '*' '+', // '+' ',', // ',' '-', // '-' '.', // '.' '/', // '/' '0', // '0' '1', // '1' '2', // '2' '3', // '3' '4', // '4' '5', // '5' '6', // '6' '7', // '7' '8', // '8' '9', // '9' ':', // ':' ';', // ';' '<', // '<' '=', // '=' '>', // '>' '?', // '?' '@', // '@' 'A', // 'A' 'B', // 'B' 'C', // 'C' 'D', // 'D' 'E', // 'E' 'F', // 'F' 'G', // 'G' 'H', // 'H' 'I', // 'I' 'J', // 'J' 'K', // 'K' 'L', // 'L' 'M', // 'M' 'N', // 'N' 'O', // 'O' 'P', // 'P' 'Q', // 'Q' 'R', // 'R' 'S', // 'S' 'T', // 'T' 'U', // 'U' 'V', // 'V' 'W', // 'W' 'X', // 'X' 'Y', // 'Y' 'Z', // 'Z' '[', // '[' '\', // '\' ']', // ']' '^', // '^' '_', // '_' '`', // '`' 'a', // 'a' 'b', // 'b' 'c', // 'c' 'd', // 'd' 'e', // 'e' 'f', // 'f' 'g', // 'g' 'h', // 'h' 'i', // 'i' 'j', // 'j' 'k', // 'k' 'l', // 'l' 'm', // 'm' 'n', // 'n' 'o', // 'o' 'p', // 'p' 'q', // 'q' 'r', // 'r' 's', // 's' 't', // 't' 'u', // 'u' 'v', // 'v' 'w', // 'w' 'x', // 'x' 'y', // 'y' 'z', // 'z' '{', // '{' '|', // '|' '}', // '}' '~', // '~' #127, // #127 #226#130#172, // #128 '', // #129 #226#128#154, // #130 #198#146, // #131 #226#128#158, // #132 #226#128#166, // #133 #226#128#160, // #134 #226#128#161, // #135 #203#134, // #136 #226#128#176, // #137 #197#160, // #138 #226#128#185, // #139 #197#146, // #140 '', // #141 #197#189, // #142 '', // #143 '', // #144 #226#128#152, // #145 #226#128#153, // #146 #226#128#156, // #147 #226#128#157, // #148 #226#128#162, // #149 #226#128#147, // #150 #226#128#148, // #151 #203#156, // #152 #226#132#162, // #153 #197#161, // #154 #226#128#186, // #155 #197#147, // #156 '', // #157 #197#190, // #158 #197#184, // #159 #194#160, // #160 #194#161, // #161 #194#162, // #162 #194#163, // #163 #194#164, // #164 #194#165, // #165 #194#166, // #166 #194#167, // #167 #194#168, // #168 #194#169, // #169 #194#170, // #170 #194#171, // #171 #194#172, // #172 #194#173, // #173 #194#174, // #174 #194#175, // #175 #194#176, // #176 #194#177, // #177 #194#178, // #178 #194#179, // #179 #194#180, // #180 #194#181, // #181 #194#182, // #182 #194#183, // #183 #194#184, // #184 #194#185, // #185 #194#186, // #186 #194#187, // #187 #194#188, // #188 #194#189, // #189 #194#190, // #190 #194#191, // #191 #195#128, // #192 #195#129, // #193 #195#130, // #194 #195#131, // #195 #195#132, // #196 #195#133, // #197 #195#134, // #198 #195#135, // #199 #195#136, // #200 #195#137, // #201 #195#138, // #202 #195#139, // #203 #195#140, // #204 #195#141, // #205 #195#142, // #206 #195#143, // #207 #195#144, // #208 #195#145, // #209 #195#146, // #210 #195#147, // #211 #195#148, // #212 #195#149, // #213 #195#150, // #214 #195#151, // #215 #195#152, // #216 #195#153, // #217 #195#154, // #218 #195#155, // #219 #195#156, // #220 #195#157, // #221 #195#158, // #222 #195#159, // #223 #195#160, // #224 #195#161, // #225 #195#162, // #226 #195#163, // #227 #195#164, // #228 #195#165, // #229 #195#166, // #230 #195#167, // #231 #195#168, // #232 #195#169, // #233 #195#170, // #234 #195#171, // #235 #195#172, // #236 #195#173, // #237 #195#174, // #238 #195#175, // #239 #195#176, // #240 #195#177, // #241 #195#178, // #242 #195#179, // #243 #195#180, // #244 #195#181, // #245 #195#182, // #246 #195#183, // #247 #195#184, // #248 #195#185, // #249 #195#186, // #250 #195#187, // #251 #195#188, // #252 #195#189, // #253 #195#190, // #254 #195#191 // #255 ); ArrayCP1253ToUTF8: TCharToUTF8Table = ( #0, // #0 #1, // #1 #2, // #2 #3, // #3 #4, // #4 #5, // #5 #6, // #6 #7, // #7 #8, // #8 #9, // #9 #10, // #10 #11, // #11 #12, // #12 #13, // #13 #14, // #14 #15, // #15 #16, // #16 #17, // #17 #18, // #18 #19, // #19 #20, // #20 #21, // #21 #22, // #22 #23, // #23 #24, // #24 #25, // #25 #26, // #26 #27, // #27 #28, // #28 #29, // #29 #30, // #30 #31, // #31 ' ', // ' ' '!', // '!' '"', // '"' '#', // '#' '$', // '$' '%', // '%' '&', // '&' '''', // '''' '(', // '(' ')', // ')' '*', // '*' '+', // '+' ',', // ',' '-', // '-' '.', // '.' '/', // '/' '0', // '0' '1', // '1' '2', // '2' '3', // '3' '4', // '4' '5', // '5' '6', // '6' '7', // '7' '8', // '8' '9', // '9' ':', // ':' ';', // ';' '<', // '<' '=', // '=' '>', // '>' '?', // '?' '@', // '@' 'A', // 'A' 'B', // 'B' 'C', // 'C' 'D', // 'D' 'E', // 'E' 'F', // 'F' 'G', // 'G' 'H', // 'H' 'I', // 'I' 'J', // 'J' 'K', // 'K' 'L', // 'L' 'M', // 'M' 'N', // 'N' 'O', // 'O' 'P', // 'P' 'Q', // 'Q' 'R', // 'R' 'S', // 'S' 'T', // 'T' 'U', // 'U' 'V', // 'V' 'W', // 'W' 'X', // 'X' 'Y', // 'Y' 'Z', // 'Z' '[', // '[' '\', // '\' ']', // ']' '^', // '^' '_', // '_' '`', // '`' 'a', // 'a' 'b', // 'b' 'c', // 'c' 'd', // 'd' 'e', // 'e' 'f', // 'f' 'g', // 'g' 'h', // 'h' 'i', // 'i' 'j', // 'j' 'k', // 'k' 'l', // 'l' 'm', // 'm' 'n', // 'n' 'o', // 'o' 'p', // 'p' 'q', // 'q' 'r', // 'r' 's', // 's' 't', // 't' 'u', // 'u' 'v', // 'v' 'w', // 'w' 'x', // 'x' 'y', // 'y' 'z', // 'z' '{', // '{' '|', // '|' '}', // '}' '~', // '~' #127, // #127 #226#130#172, // #128 '', // #129 #226#128#154, // #130 #198#146, // #131 #226#128#158, // #132 #226#128#166, // #133 #226#128#160, // #134 #226#128#161, // #135 '', // #136 #226#128#176, // #137 '', // #138 #226#128#185, // #139 '', // #140 '', // #141 '', // #142 '', // #143 '', // #144 #226#128#152, // #145 #226#128#153, // #146 #226#128#156, // #147 #226#128#157, // #148 #226#128#162, // #149 #226#128#147, // #150 #226#128#148, // #151 '', // #152 #226#132#162, // #153 '', // #154 #226#128#186, // #155 '', // #156 '', // #157 '', // #158 '', // #159 #194#160, // #160 #206#133, // #161 #206#134, // #162 #194#163, // #163 #194#164, // #164 #194#165, // #165 #194#166, // #166 #194#167, // #167 #194#168, // #168 #194#169, // #169 '', // #170 #194#171, // #171 #194#172, // #172 #194#173, // #173 #194#174, // #174 #226#128#149, // #175 #194#176, // #176 #194#177, // #177 #194#178, // #178 #194#179, // #179 #206#132, // #180 #194#181, // #181 #194#182, // #182 #194#183, // #183 #206#136, // #184 #206#137, // #185 #206#138, // #186 #194#187, // #187 #206#140, // #188 #194#189, // #189 #206#142, // #190 #206#143, // #191 #206#144, // #192 #206#145, // #193 #206#146, // #194 #206#147, // #195 #206#148, // #196 #206#149, // #197 #206#150, // #198 #206#151, // #199 #206#152, // #200 #206#153, // #201 #206#154, // #202 #206#155, // #203 #206#156, // #204 #206#157, // #205 #206#158, // #206 #206#159, // #207 #206#160, // #208 #206#161, // #209 '', // #210 #206#163, // #211 #206#164, // #212 #206#165, // #213 #206#166, // #214 #206#167, // #215 #206#168, // #216 #206#169, // #217 #206#170, // #218 #206#171, // #219 #206#172, // #220 #206#173, // #221 #206#174, // #222 #206#175, // #223 #206#176, // #224 #206#177, // #225 #206#178, // #226 #206#179, // #227 #206#180, // #228 #206#181, // #229 #206#182, // #230 #206#183, // #231 #206#184, // #232 #206#185, // #233 #206#186, // #234 #206#187, // #235 #206#188, // #236 #206#189, // #237 #206#190, // #238 #206#191, // #239 #207#128, // #240 #207#129, // #241 #207#130, // #242 #207#131, // #243 #207#132, // #244 #207#133, // #245 #207#134, // #246 #207#135, // #247 #207#136, // #248 #207#137, // #249 #207#138, // #250 #207#139, // #251 #207#140, // #252 #207#141, // #253 #207#142, // #254 '' // #255 ); ArrayCP1254ToUTF8: TCharToUTF8Table = ( #0, // #0 #1, // #1 #2, // #2 #3, // #3 #4, // #4 #5, // #5 #6, // #6 #7, // #7 #8, // #8 #9, // #9 #10, // #10 #11, // #11 #12, // #12 #13, // #13 #14, // #14 #15, // #15 #16, // #16 #17, // #17 #18, // #18 #19, // #19 #20, // #20 #21, // #21 #22, // #22 #23, // #23 #24, // #24 #25, // #25 #26, // #26 #27, // #27 #28, // #28 #29, // #29 #30, // #30 #31, // #31 ' ', // ' ' '!', // '!' '"', // '"' '#', // '#' '$', // '$' '%', // '%' '&', // '&' '''', // '''' '(', // '(' ')', // ')' '*', // '*' '+', // '+' ',', // ',' '-', // '-' '.', // '.' '/', // '/' '0', // '0' '1', // '1' '2', // '2' '3', // '3' '4', // '4' '5', // '5' '6', // '6' '7', // '7' '8', // '8' '9', // '9' ':', // ':' ';', // ';' '<', // '<' '=', // '=' '>', // '>' '?', // '?' '@', // '@' 'A', // 'A' 'B', // 'B' 'C', // 'C' 'D', // 'D' 'E', // 'E' 'F', // 'F' 'G', // 'G' 'H', // 'H' 'I', // 'I' 'J', // 'J' 'K', // 'K' 'L', // 'L' 'M', // 'M' 'N', // 'N' 'O', // 'O' 'P', // 'P' 'Q', // 'Q' 'R', // 'R' 'S', // 'S' 'T', // 'T' 'U', // 'U' 'V', // 'V' 'W', // 'W' 'X', // 'X' 'Y', // 'Y' 'Z', // 'Z' '[', // '[' '\', // '\' ']', // ']' '^', // '^' '_', // '_' '`', // '`' 'a', // 'a' 'b', // 'b' 'c', // 'c' 'd', // 'd' 'e', // 'e' 'f', // 'f' 'g', // 'g' 'h', // 'h' 'i', // 'i' 'j', // 'j' 'k', // 'k' 'l', // 'l' 'm', // 'm' 'n', // 'n' 'o', // 'o' 'p', // 'p' 'q', // 'q' 'r', // 'r' 's', // 's' 't', // 't' 'u', // 'u' 'v', // 'v' 'w', // 'w' 'x', // 'x' 'y', // 'y' 'z', // 'z' '{', // '{' '|', // '|' '}', // '}' '~', // '~' #127, // #127 #226#130#172, // #128 '', // #129 #226#128#154, // #130 #198#146, // #131 #226#128#158, // #132 #226#128#166, // #133 #226#128#160, // #134 #226#128#161, // #135 #203#134, // #136 #226#128#176, // #137 #197#160, // #138 #226#128#185, // #139 #197#146, // #140 '', // #141 '', // #142 '', // #143 '', // #144 #226#128#152, // #145 #226#128#153, // #146 #226#128#156, // #147 #226#128#157, // #148 #226#128#162, // #149 #226#128#147, // #150 #226#128#148, // #151 #203#156, // #152 #226#132#162, // #153 #197#161, // #154 #226#128#186, // #155 #197#147, // #156 '', // #157 '', // #158 #197#184, // #159 #194#160, // #160 #194#161, // #161 #194#162, // #162 #194#163, // #163 #194#164, // #164 #194#165, // #165 #194#166, // #166 #194#167, // #167 #194#168, // #168 #194#169, // #169 #194#170, // #170 #194#171, // #171 #194#172, // #172 #194#173, // #173 #194#174, // #174 #194#175, // #175 #194#176, // #176 #194#177, // #177 #194#178, // #178 #194#179, // #179 #194#180, // #180 #194#181, // #181 #194#182, // #182 #194#183, // #183 #194#184, // #184 #194#185, // #185 #194#186, // #186 #194#187, // #187 #194#188, // #188 #194#189, // #189 #194#190, // #190 #194#191, // #191 #195#128, // #192 #195#129, // #193 #195#130, // #194 #195#131, // #195 #195#132, // #196 #195#133, // #197 #195#134, // #198 #195#135, // #199 #195#136, // #200 #195#137, // #201 #195#138, // #202 #195#139, // #203 #195#140, // #204 #195#141, // #205 #195#142, // #206 #195#143, // #207 #196#158, // #208 #195#145, // #209 #195#146, // #210 #195#147, // #211 #195#148, // #212 #195#149, // #213 #195#150, // #214 #195#151, // #215 #195#152, // #216 #195#153, // #217 #195#154, // #218 #195#155, // #219 #195#156, // #220 #196#176, // #221 #197#158, // #222 #195#159, // #223 #195#160, // #224 #195#161, // #225 #195#162, // #226 #195#163, // #227 #195#164, // #228 #195#165, // #229 #195#166, // #230 #195#167, // #231 #195#168, // #232 #195#169, // #233 #195#170, // #234 #195#171, // #235 #195#172, // #236 #195#173, // #237 #195#174, // #238 #195#175, // #239 #196#159, // #240 #195#177, // #241 #195#178, // #242 #195#179, // #243 #195#180, // #244 #195#181, // #245 #195#182, // #246 #195#183, // #247 #195#184, // #248 #195#185, // #249 #195#186, // #250 #195#187, // #251 #195#188, // #252 #196#177, // #253 #197#159, // #254 #195#191 // #255 ); ArrayCP1255ToUTF8: TCharToUTF8Table = ( #0, // #0 #1, // #1 #2, // #2 #3, // #3 #4, // #4 #5, // #5 #6, // #6 #7, // #7 #8, // #8 #9, // #9 #10, // #10 #11, // #11 #12, // #12 #13, // #13 #14, // #14 #15, // #15 #16, // #16 #17, // #17 #18, // #18 #19, // #19 #20, // #20 #21, // #21 #22, // #22 #23, // #23 #24, // #24 #25, // #25 #26, // #26 #27, // #27 #28, // #28 #29, // #29 #30, // #30 #31, // #31 ' ', // ' ' '!', // '!' '"', // '"' '#', // '#' '$', // '$' '%', // '%' '&', // '&' '''', // '''' '(', // '(' ')', // ')' '*', // '*' '+', // '+' ',', // ',' '-', // '-' '.', // '.' '/', // '/' '0', // '0' '1', // '1' '2', // '2' '3', // '3' '4', // '4' '5', // '5' '6', // '6' '7', // '7' '8', // '8' '9', // '9' ':', // ':' ';', // ';' '<', // '<' '=', // '=' '>', // '>' '?', // '?' '@', // '@' 'A', // 'A' 'B', // 'B' 'C', // 'C' 'D', // 'D' 'E', // 'E' 'F', // 'F' 'G', // 'G' 'H', // 'H' 'I', // 'I' 'J', // 'J' 'K', // 'K' 'L', // 'L' 'M', // 'M' 'N', // 'N' 'O', // 'O' 'P', // 'P' 'Q', // 'Q' 'R', // 'R' 'S', // 'S' 'T', // 'T' 'U', // 'U' 'V', // 'V' 'W', // 'W' 'X', // 'X' 'Y', // 'Y' 'Z', // 'Z' '[', // '[' '\', // '\' ']', // ']' '^', // '^' '_', // '_' '`', // '`' 'a', // 'a' 'b', // 'b' 'c', // 'c' 'd', // 'd' 'e', // 'e' 'f', // 'f' 'g', // 'g' 'h', // 'h' 'i', // 'i' 'j', // 'j' 'k', // 'k' 'l', // 'l' 'm', // 'm' 'n', // 'n' 'o', // 'o' 'p', // 'p' 'q', // 'q' 'r', // 'r' 's', // 's' 't', // 't' 'u', // 'u' 'v', // 'v' 'w', // 'w' 'x', // 'x' 'y', // 'y' 'z', // 'z' '{', // '{' '|', // '|' '}', // '}' '~', // '~' #127, // #127 #226#130#172, // #128 '', // #129 #226#128#154, // #130 #198#146, // #131 #226#128#158, // #132 #226#128#166, // #133 #226#128#160, // #134 #226#128#161, // #135 #203#134, // #136 #226#128#176, // #137 '', // #138 #226#128#185, // #139 '', // #140 '', // #141 '', // #142 '', // #143 '', // #144 #226#128#152, // #145 #226#128#153, // #146 #226#128#156, // #147 #226#128#157, // #148 #226#128#162, // #149 #226#128#147, // #150 #226#128#148, // #151 #203#156, // #152 #226#132#162, // #153 '', // #154 #226#128#186, // #155 '', // #156 '', // #157 '', // #158 '', // #159 #194#160, // #160 #194#161, // #161 #194#162, // #162 #194#163, // #163 #226#130#170, // #164 #194#165, // #165 #194#166, // #166 #194#167, // #167 #194#168, // #168 #194#169, // #169 #195#151, // #170 #194#171, // #171 #194#172, // #172 #194#173, // #173 #194#174, // #174 #194#175, // #175 #194#176, // #176 #194#177, // #177 #194#178, // #178 #194#179, // #179 #194#180, // #180 #194#181, // #181 #194#182, // #182 #194#183, // #183 #194#184, // #184 #194#185, // #185 #195#183, // #186 #194#187, // #187 #194#188, // #188 #194#189, // #189 #194#190, // #190 #194#191, // #191 #214#176, // #192 #214#177, // #193 #214#178, // #194 #214#179, // #195 #214#180, // #196 #214#181, // #197 #214#182, // #198 #214#183, // #199 #214#184, // #200 #214#185, // #201 '', // #202 #214#187, // #203 #214#188, // #204 #214#189, // #205 #214#190, // #206 #214#191, // #207 #215#128, // #208 #215#129, // #209 #215#130, // #210 #215#131, // #211 #215#176, // #212 #215#177, // #213 #215#178, // #214 #215#179, // #215 #215#180, // #216 '', // #217 '', // #218 '', // #219 '', // #220 '', // #221 '', // #222 '', // #223 #215#144, // #224 #215#145, // #225 #215#146, // #226 #215#147, // #227 #215#148, // #228 #215#149, // #229 #215#150, // #230 #215#151, // #231 #215#152, // #232 #215#153, // #233 #215#154, // #234 #215#155, // #235 #215#156, // #236 #215#157, // #237 #215#158, // #238 #215#159, // #239 #215#160, // #240 #215#161, // #241 #215#162, // #242 #215#163, // #243 #215#164, // #244 #215#165, // #245 #215#166, // #246 #215#167, // #247 #215#168, // #248 #215#169, // #249 #215#170, // #250 '', // #251 '', // #252 #226#128#142, // #253 #226#128#143, // #254 '' // #255 ); ArrayCP1256ToUTF8: TCharToUTF8Table = ( #0, // #0 #1, // #1 #2, // #2 #3, // #3 #4, // #4 #5, // #5 #6, // #6 #7, // #7 #8, // #8 #9, // #9 #10, // #10 #11, // #11 #12, // #12 #13, // #13 #14, // #14 #15, // #15 #16, // #16 #17, // #17 #18, // #18 #19, // #19 #20, // #20 #21, // #21 #22, // #22 #23, // #23 #24, // #24 #25, // #25 #26, // #26 #27, // #27 #28, // #28 #29, // #29 #30, // #30 #31, // #31 ' ', // ' ' '!', // '!' '"', // '"' '#', // '#' '$', // '$' '%', // '%' '&', // '&' '''', // '''' '(', // '(' ')', // ')' '*', // '*' '+', // '+' ',', // ',' '-', // '-' '.', // '.' '/', // '/' '0', // '0' '1', // '1' '2', // '2' '3', // '3' '4', // '4' '5', // '5' '6', // '6' '7', // '7' '8', // '8' '9', // '9' ':', // ':' ';', // ';' '<', // '<' '=', // '=' '>', // '>' '?', // '?' '@', // '@' 'A', // 'A' 'B', // 'B' 'C', // 'C' 'D', // 'D' 'E', // 'E' 'F', // 'F' 'G', // 'G' 'H', // 'H' 'I', // 'I' 'J', // 'J' 'K', // 'K' 'L', // 'L' 'M', // 'M' 'N', // 'N' 'O', // 'O' 'P', // 'P' 'Q', // 'Q' 'R', // 'R' 'S', // 'S' 'T', // 'T' 'U', // 'U' 'V', // 'V' 'W', // 'W' 'X', // 'X' 'Y', // 'Y' 'Z', // 'Z' '[', // '[' '\', // '\' ']', // ']' '^', // '^' '_', // '_' '`', // '`' 'a', // 'a' 'b', // 'b' 'c', // 'c' 'd', // 'd' 'e', // 'e' 'f', // 'f' 'g', // 'g' 'h', // 'h' 'i', // 'i' 'j', // 'j' 'k', // 'k' 'l', // 'l' 'm', // 'm' 'n', // 'n' 'o', // 'o' 'p', // 'p' 'q', // 'q' 'r', // 'r' 's', // 's' 't', // 't' 'u', // 'u' 'v', // 'v' 'w', // 'w' 'x', // 'x' 'y', // 'y' 'z', // 'z' '{', // '{' '|', // '|' '}', // '}' '~', // '~' #127, // #127 #226#130#172, // #128 #217#190, // #129 #226#128#154, // #130 #198#146, // #131 #226#128#158, // #132 #226#128#166, // #133 #226#128#160, // #134 #226#128#161, // #135 #203#134, // #136 #226#128#176, // #137 #217#185, // #138 #226#128#185, // #139 #197#146, // #140 #218#134, // #141 #218#152, // #142 #218#136, // #143 #218#175, // #144 #226#128#152, // #145 #226#128#153, // #146 #226#128#156, // #147 #226#128#157, // #148 #226#128#162, // #149 #226#128#147, // #150 #226#128#148, // #151 #218#169, // #152 #226#132#162, // #153 #218#145, // #154 #226#128#186, // #155 #197#147, // #156 #226#128#140, // #157 #226#128#141, // #158 #218#186, // #159 #194#160, // #160 #216#140, // #161 #194#162, // #162 #194#163, // #163 #194#164, // #164 #194#165, // #165 #194#166, // #166 #194#167, // #167 #194#168, // #168 #194#169, // #169 #218#190, // #170 #194#171, // #171 #194#172, // #172 #194#173, // #173 #194#174, // #174 #194#175, // #175 #194#176, // #176 #194#177, // #177 #194#178, // #178 #194#179, // #179 #194#180, // #180 #194#181, // #181 #194#182, // #182 #194#183, // #183 #194#184, // #184 #194#185, // #185 #216#155, // #186 #194#187, // #187 #194#188, // #188 #194#189, // #189 #194#190, // #190 #216#159, // #191 #219#129, // #192 #216#161, // #193 #216#162, // #194 #216#163, // #195 #216#164, // #196 #216#165, // #197 #216#166, // #198 #216#167, // #199 #216#168, // #200 #216#169, // #201 #216#170, // #202 #216#171, // #203 #216#172, // #204 #216#173, // #205 #216#174, // #206 #216#175, // #207 #216#176, // #208 #216#177, // #209 #216#178, // #210 #216#179, // #211 #216#180, // #212 #216#181, // #213 #216#182, // #214 #195#151, // #215 #216#183, // #216 #216#184, // #217 #216#185, // #218 #216#186, // #219 #217#128, // #220 #217#129, // #221 #217#130, // #222 #217#131, // #223 #195#160, // #224 #217#132, // #225 #195#162, // #226 #217#133, // #227 #217#134, // #228 #217#135, // #229 #217#136, // #230 #195#167, // #231 #195#168, // #232 #195#169, // #233 #195#170, // #234 #195#171, // #235 #217#137, // #236 #217#138, // #237 #195#174, // #238 #195#175, // #239 #217#139, // #240 #217#140, // #241 #217#141, // #242 #217#142, // #243 #195#180, // #244 #217#143, // #245 #217#144, // #246 #195#183, // #247 #217#145, // #248 #195#185, // #249 #217#146, // #250 #195#187, // #251 #195#188, // #252 #226#128#142, // #253 #226#128#143, // #254 #219#146 // #255 ); ArrayCP1257ToUTF8: TCharToUTF8Table = ( #0, // #0 #1, // #1 #2, // #2 #3, // #3 #4, // #4 #5, // #5 #6, // #6 #7, // #7 #8, // #8 #9, // #9 #10, // #10 #11, // #11 #12, // #12 #13, // #13 #14, // #14 #15, // #15 #16, // #16 #17, // #17 #18, // #18 #19, // #19 #20, // #20 #21, // #21 #22, // #22 #23, // #23 #24, // #24 #25, // #25 #26, // #26 #27, // #27 #28, // #28 #29, // #29 #30, // #30 #31, // #31 ' ', // ' ' '!', // '!' '"', // '"' '#', // '#' '$', // '$' '%', // '%' '&', // '&' '''', // '''' '(', // '(' ')', // ')' '*', // '*' '+', // '+' ',', // ',' '-', // '-' '.', // '.' '/', // '/' '0', // '0' '1', // '1' '2', // '2' '3', // '3' '4', // '4' '5', // '5' '6', // '6' '7', // '7' '8', // '8' '9', // '9' ':', // ':' ';', // ';' '<', // '<' '=', // '=' '>', // '>' '?', // '?' '@', // '@' 'A', // 'A' 'B', // 'B' 'C', // 'C' 'D', // 'D' 'E', // 'E' 'F', // 'F' 'G', // 'G' 'H', // 'H' 'I', // 'I' 'J', // 'J' 'K', // 'K' 'L', // 'L' 'M', // 'M' 'N', // 'N' 'O', // 'O' 'P', // 'P' 'Q', // 'Q' 'R', // 'R' 'S', // 'S' 'T', // 'T' 'U', // 'U' 'V', // 'V' 'W', // 'W' 'X', // 'X' 'Y', // 'Y' 'Z', // 'Z' '[', // '[' '\', // '\' ']', // ']' '^', // '^' '_', // '_' '`', // '`' 'a', // 'a' 'b', // 'b' 'c', // 'c' 'd', // 'd' 'e', // 'e' 'f', // 'f' 'g', // 'g' 'h', // 'h' 'i', // 'i' 'j', // 'j' 'k', // 'k' 'l', // 'l' 'm', // 'm' 'n', // 'n' 'o', // 'o' 'p', // 'p' 'q', // 'q' 'r', // 'r' 's', // 's' 't', // 't' 'u', // 'u' 'v', // 'v' 'w', // 'w' 'x', // 'x' 'y', // 'y' 'z', // 'z' '{', // '{' '|', // '|' '}', // '}' '~', // '~' #127, // #127 #226#130#172, // #128 '', // #129 #226#128#154, // #130 '', // #131 #226#128#158, // #132 #226#128#166, // #133 #226#128#160, // #134 #226#128#161, // #135 '', // #136 #226#128#176, // #137 '', // #138 #226#128#185, // #139 '', // #140 #194#168, // #141 #203#135, // #142 #194#184, // #143 '', // #144 #226#128#152, // #145 #226#128#153, // #146 #226#128#156, // #147 #226#128#157, // #148 #226#128#162, // #149 #226#128#147, // #150 #226#128#148, // #151 '', // #152 #226#132#162, // #153 '', // #154 #226#128#186, // #155 '', // #156 #194#175, // #157 #203#155, // #158 '', // #159 #194#160, // #160 '', // #161 #194#162, // #162 #194#163, // #163 #194#164, // #164 '', // #165 #194#166, // #166 #194#167, // #167 #195#152, // #168 #194#169, // #169 #197#150, // #170 #194#171, // #171 #194#172, // #172 #194#173, // #173 #194#174, // #174 #195#134, // #175 #194#176, // #176 #194#177, // #177 #194#178, // #178 #194#179, // #179 #194#180, // #180 #194#181, // #181 #194#182, // #182 #194#183, // #183 #195#184, // #184 #194#185, // #185 #197#151, // #186 #194#187, // #187 #194#188, // #188 #194#189, // #189 #194#190, // #190 #195#166, // #191 #196#132, // #192 #196#174, // #193 #196#128, // #194 #196#134, // #195 #195#132, // #196 #195#133, // #197 #196#152, // #198 #196#146, // #199 #196#140, // #200 #195#137, // #201 #197#185, // #202 #196#150, // #203 #196#162, // #204 #196#182, // #205 #196#170, // #206 #196#187, // #207 #197#160, // #208 #197#131, // #209 #197#133, // #210 #195#147, // #211 #197#140, // #212 #195#149, // #213 #195#150, // #214 #195#151, // #215 #197#178, // #216 #197#129, // #217 #197#154, // #218 #197#170, // #219 #195#156, // #220 #197#187, // #221 #197#189, // #222 #195#159, // #223 #196#133, // #224 #196#175, // #225 #196#129, // #226 #196#135, // #227 #195#164, // #228 #195#165, // #229 #196#153, // #230 #196#147, // #231 #196#141, // #232 #195#169, // #233 #197#186, // #234 #196#151, // #235 #196#163, // #236 #196#183, // #237 #196#171, // #238 #196#188, // #239 #197#161, // #240 #197#132, // #241 #197#134, // #242 #195#179, // #243 #197#141, // #244 #195#181, // #245 #195#182, // #246 #195#183, // #247 #197#179, // #248 #197#130, // #249 #197#155, // #250 #197#171, // #251 #195#188, // #252 #197#188, // #253 #197#190, // #254 #203#153 // #255 ); ArrayCP1258ToUTF8: TCharToUTF8Table = ( #0, // #0 #1, // #1 #2, // #2 #3, // #3 #4, // #4 #5, // #5 #6, // #6 #7, // #7 #8, // #8 #9, // #9 #10, // #10 #11, // #11 #12, // #12 #13, // #13 #14, // #14 #15, // #15 #16, // #16 #17, // #17 #18, // #18 #19, // #19 #20, // #20 #21, // #21 #22, // #22 #23, // #23 #24, // #24 #25, // #25 #26, // #26 #27, // #27 #28, // #28 #29, // #29 #30, // #30 #31, // #31 ' ', // ' ' '!', // '!' '"', // '"' '#', // '#' '$', // '$' '%', // '%' '&', // '&' '''', // '''' '(', // '(' ')', // ')' '*', // '*' '+', // '+' ',', // ',' '-', // '-' '.', // '.' '/', // '/' '0', // '0' '1', // '1' '2', // '2' '3', // '3' '4', // '4' '5', // '5' '6', // '6' '7', // '7' '8', // '8' '9', // '9' ':', // ':' ';', // ';' '<', // '<' '=', // '=' '>', // '>' '?', // '?' '@', // '@' 'A', // 'A' 'B', // 'B' 'C', // 'C' 'D', // 'D' 'E', // 'E' 'F', // 'F' 'G', // 'G' 'H', // 'H' 'I', // 'I' 'J', // 'J' 'K', // 'K' 'L', // 'L' 'M', // 'M' 'N', // 'N' 'O', // 'O' 'P', // 'P' 'Q', // 'Q' 'R', // 'R' 'S', // 'S' 'T', // 'T' 'U', // 'U' 'V', // 'V' 'W', // 'W' 'X', // 'X' 'Y', // 'Y' 'Z', // 'Z' '[', // '[' '\', // '\' ']', // ']' '^', // '^' '_', // '_' '`', // '`' 'a', // 'a' 'b', // 'b' 'c', // 'c' 'd', // 'd' 'e', // 'e' 'f', // 'f' 'g', // 'g' 'h', // 'h' 'i', // 'i' 'j', // 'j' 'k', // 'k' 'l', // 'l' 'm', // 'm' 'n', // 'n' 'o', // 'o' 'p', // 'p' 'q', // 'q' 'r', // 'r' 's', // 's' 't', // 't' 'u', // 'u' 'v', // 'v' 'w', // 'w' 'x', // 'x' 'y', // 'y' 'z', // 'z' '{', // '{' '|', // '|' '}', // '}' '~', // '~' #127, // #127 #226#130#172, // #128 '', // #129 #226#128#154, // #130 #198#146, // #131 #226#128#158, // #132 #226#128#166, // #133 #226#128#160, // #134 #226#128#161, // #135 #203#134, // #136 #226#128#176, // #137 '', // #138 #226#128#185, // #139 #197#146, // #140 '', // #141 '', // #142 '', // #143 '', // #144 #226#128#152, // #145 #226#128#153, // #146 #226#128#156, // #147 #226#128#157, // #148 #226#128#162, // #149 #226#128#147, // #150 #226#128#148, // #151 #203#156, // #152 #226#132#162, // #153 '', // #154 #226#128#186, // #155 #197#147, // #156 '', // #157 '', // #158 #197#184, // #159 #194#160, // #160 #194#161, // #161 #194#162, // #162 #194#163, // #163 #194#164, // #164 #194#165, // #165 #194#166, // #166 #194#167, // #167 #194#168, // #168 #194#169, // #169 #194#170, // #170 #194#171, // #171 #194#172, // #172 #194#173, // #173 #194#174, // #174 #194#175, // #175 #194#176, // #176 #194#177, // #177 #194#178, // #178 #194#179, // #179 #194#180, // #180 #194#181, // #181 #194#182, // #182 #194#183, // #183 #194#184, // #184 #194#185, // #185 #194#186, // #186 #194#187, // #187 #194#188, // #188 #194#189, // #189 #194#190, // #190 #194#191, // #191 #195#128, // #192 #195#129, // #193 #195#130, // #194 #196#130, // #195 #195#132, // #196 #195#133, // #197 #195#134, // #198 #195#135, // #199 #195#136, // #200 #195#137, // #201 #195#138, // #202 #195#139, // #203 #204#128, // #204 #195#141, // #205 #195#142, // #206 #195#143, // #207 #196#144, // #208 #195#145, // #209 #204#137, // #210 #195#147, // #211 #195#148, // #212 #198#160, // #213 #195#150, // #214 #195#151, // #215 #195#152, // #216 #195#153, // #217 #195#154, // #218 #195#155, // #219 #195#156, // #220 #198#175, // #221 #204#131, // #222 #195#159, // #223 #195#160, // #224 #195#161, // #225 #195#162, // #226 #196#131, // #227 #195#164, // #228 #195#165, // #229 #195#166, // #230 #195#167, // #231 #195#168, // #232 #195#169, // #233 #195#170, // #234 #195#171, // #235 #204#129, // #236 #195#173, // #237 #195#174, // #238 #195#175, // #239 #196#145, // #240 #195#177, // #241 #204#163, // #242 #195#179, // #243 #195#180, // #244 #198#161, // #245 #195#182, // #246 #195#183, // #247 #195#184, // #248 #195#185, // #249 #195#186, // #250 #195#187, // #251 #195#188, // #252 #198#176, // #253 #226#130#171, // #254 #195#191 // #255 ); ArrayCP874ToUTF8: TCharToUTF8Table = ( #0, // #0 #1, // #1 #2, // #2 #3, // #3 #4, // #4 #5, // #5 #6, // #6 #7, // #7 #8, // #8 #9, // #9 #10, // #10 #11, // #11 #12, // #12 #13, // #13 #14, // #14 #15, // #15 #16, // #16 #17, // #17 #18, // #18 #19, // #19 #20, // #20 #21, // #21 #22, // #22 #23, // #23 #24, // #24 #25, // #25 #26, // #26 #27, // #27 #28, // #28 #29, // #29 #30, // #30 #31, // #31 ' ', // ' ' '!', // '!' '"', // '"' '#', // '#' '$', // '$' '%', // '%' '&', // '&' '''', // '''' '(', // '(' ')', // ')' '*', // '*' '+', // '+' ',', // ',' '-', // '-' '.', // '.' '/', // '/' '0', // '0' '1', // '1' '2', // '2' '3', // '3' '4', // '4' '5', // '5' '6', // '6' '7', // '7' '8', // '8' '9', // '9' ':', // ':' ';', // ';' '<', // '<' '=', // '=' '>', // '>' '?', // '?' '@', // '@' 'A', // 'A' 'B', // 'B' 'C', // 'C' 'D', // 'D' 'E', // 'E' 'F', // 'F' 'G', // 'G' 'H', // 'H' 'I', // 'I' 'J', // 'J' 'K', // 'K' 'L', // 'L' 'M', // 'M' 'N', // 'N' 'O', // 'O' 'P', // 'P' 'Q', // 'Q' 'R', // 'R' 'S', // 'S' 'T', // 'T' 'U', // 'U' 'V', // 'V' 'W', // 'W' 'X', // 'X' 'Y', // 'Y' 'Z', // 'Z' '[', // '[' '\', // '\' ']', // ']' '^', // '^' '_', // '_' '`', // '`' 'a', // 'a' 'b', // 'b' 'c', // 'c' 'd', // 'd' 'e', // 'e' 'f', // 'f' 'g', // 'g' 'h', // 'h' 'i', // 'i' 'j', // 'j' 'k', // 'k' 'l', // 'l' 'm', // 'm' 'n', // 'n' 'o', // 'o' 'p', // 'p' 'q', // 'q' 'r', // 'r' 's', // 's' 't', // 't' 'u', // 'u' 'v', // 'v' 'w', // 'w' 'x', // 'x' 'y', // 'y' 'z', // 'z' '{', // '{' '|', // '|' '}', // '}' '~', // '~' #127, // #127 #226#130#172, // #128 '', // #129 '', // #130 '', // #131 '', // #132 #226#128#166, // #133 '', // #134 '', // #135 '', // #136 '', // #137 '', // #138 '', // #139 '', // #140 '', // #141 '', // #142 '', // #143 '', // #144 #226#128#152, // #145 #226#128#153, // #146 #226#128#156, // #147 #226#128#157, // #148 #226#128#162, // #149 #226#128#147, // #150 #226#128#148, // #151 '', // #152 '', // #153 '', // #154 '', // #155 '', // #156 '', // #157 '', // #158 '', // #159 #194#160, // #160 #224#184#129, // #161 #224#184#130, // #162 #224#184#131, // #163 #224#184#132, // #164 #224#184#133, // #165 #224#184#134, // #166 #224#184#135, // #167 #224#184#136, // #168 #224#184#137, // #169 #224#184#138, // #170 #224#184#139, // #171 #224#184#140, // #172 #224#184#141, // #173 #224#184#142, // #174 #224#184#143, // #175 #224#184#144, // #176 #224#184#145, // #177 #224#184#146, // #178 #224#184#147, // #179 #224#184#148, // #180 #224#184#149, // #181 #224#184#150, // #182 #224#184#151, // #183 #224#184#152, // #184 #224#184#153, // #185 #224#184#154, // #186 #224#184#155, // #187 #224#184#156, // #188 #224#184#157, // #189 #224#184#158, // #190 #224#184#159, // #191 #224#184#160, // #192 #224#184#161, // #193 #224#184#162, // #194 #224#184#163, // #195 #224#184#164, // #196 #224#184#165, // #197 #224#184#166, // #198 #224#184#167, // #199 #224#184#168, // #200 #224#184#169, // #201 #224#184#170, // #202 #224#184#171, // #203 #224#184#172, // #204 #224#184#173, // #205 #224#184#174, // #206 #224#184#175, // #207 #224#184#176, // #208 #224#184#177, // #209 #224#184#178, // #210 #224#184#179, // #211 #224#184#180, // #212 #224#184#181, // #213 #224#184#182, // #214 #224#184#183, // #215 #224#184#184, // #216 #224#184#185, // #217 #224#184#186, // #218 '', // #219 '', // #220 '', // #221 '', // #222 #224#184#191, // #223 #224#185#128, // #224 #224#185#129, // #225 #224#185#130, // #226 #224#185#131, // #227 #224#185#132, // #228 #224#185#133, // #229 #224#185#134, // #230 #224#185#135, // #231 #224#185#136, // #232 #224#185#137, // #233 #224#185#138, // #234 #224#185#139, // #235 #224#185#140, // #236 #224#185#141, // #237 #224#185#142, // #238 #224#185#143, // #239 #224#185#144, // #240 #224#185#145, // #241 #224#185#146, // #242 #224#185#147, // #243 #224#185#148, // #244 #224#185#149, // #245 #224#185#150, // #246 #224#185#151, // #247 #224#185#152, // #248 #224#185#153, // #249 #224#185#154, // #250 #224#185#155, // #251 '', // #252 '', // #253 '', // #254 '' // #255 ); ArrayKOI8ToUTF8: TCharToUTF8Table = ( #0, // #0 #1, // #1 #2, // #2 #3, // #3 #4, // #4 #5, // #5 #6, // #6 #7, // #7 #8, // #8 #9, // #9 #10, // #10 #11, // #11 #12, // #12 #13, // #13 #14, // #14 #15, // #15 #16, // #16 #17, // #17 #18, // #18 #19, // #19 #20, // #20 #21, // #21 #22, // #22 #23, // #23 #24, // #24 #25, // #25 #26, // #26 #27, // #27 #28, // #28 #29, // #29 #30, // #30 #31, // #31 ' ', // ' ' '!', // '!' '"', // '"' '#', // '#' '$', // '$' '%', // '%' '&', // '&' '''', // '''' '(', // '(' ')', // ')' '*', // '*' '+', // '+' ',', // ',' '-', // '-' '.', // '.' '/', // '/' '0', // '0' '1', // '1' '2', // '2' '3', // '3' '4', // '4' '5', // '5' '6', // '6' '7', // '7' '8', // '8' '9', // '9' ':', // ':' ';', // ';' '<', // '<' '=', // '=' '>', // '>' '?', // '?' '@', // '@' 'A', // 'A' 'B', // 'B' 'C', // 'C' 'D', // 'D' 'E', // 'E' 'F', // 'F' 'G', // 'G' 'H', // 'H' 'I', // 'I' 'J', // 'J' 'K', // 'K' 'L', // 'L' 'M', // 'M' 'N', // 'N' 'O', // 'O' 'P', // 'P' 'Q', // 'Q' 'R', // 'R' 'S', // 'S' 'T', // 'T' 'U', // 'U' 'V', // 'V' 'W', // 'W' 'X', // 'X' 'Y', // 'Y' 'Z', // 'Z' '[', // '[' '\', // '\' ']', // ']' '^', // '^' '_', // '_' '`', // '`' 'a', // 'a' 'b', // 'b' 'c', // 'c' 'd', // 'd' 'e', // 'e' 'f', // 'f' 'g', // 'g' 'h', // 'h' 'i', // 'i' 'j', // 'j' 'k', // 'k' 'l', // 'l' 'm', // 'm' 'n', // 'n' 'o', // 'o' 'p', // 'p' 'q', // 'q' 'r', // 'r' 's', // 's' 't', // 't' 'u', // 'u' 'v', // 'v' 'w', // 'w' 'x', // 'x' 'y', // 'y' 'z', // 'z' '{', // '{' '|', // '|' '}', // '}' '~', // '~' #127, // #127 '', // #128 '', // #129 '', // #130 '', // #131 '', // #132 '', // #133 '', // #134 '', // #135 '', // #136 '', // #137 '', // #138 '', // #139 '', // #140 '', // #141 '', // #142 '', // #143 '', // #144 '', // #145 '', // #146 '', // #147 '', // #148 '', // #149 '', // #150 '', // #151 '', // #152 '', // #153 '', // #154 '', // #155 '', // #156 '', // #157 '', // #158 '', // #159 '', // #160 '', // #161 '', // #162 '', // #163 '', // #164 '', // #165 '', // #166 '', // #167 '', // #168 '', // #169 '', // #170 '', // #171 '', // #172 '', // #173 '', // #174 '', // #175 '', // #176 '', // #177 '', // #178 '', // #179 '', // #180 '', // #181 '', // #182 '', // #183 '', // #184 '', // #185 '', // #186 '', // #187 '', // #188 '', // #189 '', // #190 '', // #191 #209#142, // #192 #208#176, // #193 #208#177, // #194 #209#134, // #195 #208#180, // #196 #208#181, // #197 #209#132, // #198 #208#179, // #199 #209#133, // #200 #208#184, // #201 #208#185, // #202 #208#186, // #203 #208#187, // #204 #208#188, // #205 #208#189, // #206 #208#190, // #207 #208#191, // #208 #209#143, // #209 #209#128, // #210 #209#129, // #211 #209#130, // #212 #209#131, // #213 #208#182, // #214 #208#178, // #215 #209#140, // #216 #209#139, // #217 #208#183, // #218 #209#136, // #219 #209#141, // #220 #209#137, // #221 #209#135, // #222 #209#138, // #223 #208#174, // #224 #208#144, // #225 #208#145, // #226 #208#166, // #227 #208#148, // #228 #208#149, // #229 #208#164, // #230 #208#147, // #231 #208#165, // #232 #208#152, // #233 #208#153, // #234 #208#154, // #235 #208#155, // #236 #208#156, // #237 #208#157, // #238 #208#158, // #239 #208#159, // #240 #208#175, // #241 #208#160, // #242 #208#161, // #243 #208#162, // #244 #208#163, // #245 #208#150, // #246 #208#146, // #247 #208#172, // #248 #208#171, // #249 #208#151, // #250 #208#168, // #251 #208#173, // #252 #208#169, // #253 #208#167, // #254 '' // #255 ); function ISO_8859_1ToUTF8(const s: string): string; begin Result:=SingleByteToUTF8(s,ArrayISO_8859_1ToUTF8); end; function CP1250ToUTF8(const s: string): string; begin Result:=SingleByteToUTF8(s,ArrayCP1250ToUTF8); end; function CP1251ToUTF8(const s: string): string; begin Result:=SingleByteToUTF8(s,ArrayCP1251ToUTF8); end; function CP1252ToUTF8(const s: string): string; begin Result:=SingleByteToUTF8(s,ArrayCP1252ToUTF8); end; function CP1253ToUTF8(const s: string): string; begin Result:=SingleByteToUTF8(s,ArrayCP1253ToUTF8); end; function CP1254ToUTF8(const s: string): string; begin Result:=SingleByteToUTF8(s,ArrayCP1254ToUTF8); end; function CP1255ToUTF8(const s: string): string; begin Result:=SingleByteToUTF8(s,ArrayCP1255ToUTF8); end; function CP1256ToUTF8(const s: string): string; begin Result:=SingleByteToUTF8(s,ArrayCP1256ToUTF8); end; function CP1257ToUTF8(const s: string): string; begin Result:=SingleByteToUTF8(s,ArrayCP1257ToUTF8); end; function CP1258ToUTF8(const s: string): string; begin Result:=SingleByteToUTF8(s,ArrayCP1258ToUTF8); end; function CP874ToUTF8(const s: string): string; begin Result:=SingleByteToUTF8(s,ArrayCP874ToUTF8); end; function KOI8ToUTF8(const s: string): string; begin Result:=SingleByteToUTF8(s,ArrayKOI8ToUTF8); end; function SingleByteToUTF8(const s: string; const Table: TCharToUTF8Table ): string; var len: Integer; i: Integer; Src: PChar; Dest: PChar; p: PChar; c: Char; begin if s='' then begin Result:=s; exit; end; len:=length(s); SetLength(Result,len*4);// UTF-8 is at most 4 bytes Src:=PChar(s); Dest:=PChar(Result); for i:=1 to len do begin c:=Src^; inc(Src); if ord(c)<128 then begin Dest^:=c; inc(Dest); end else begin p:=Table[c]; if p<>nil then begin while p^<>#0 do begin Dest^:=p^; inc(p); inc(Dest); end; end; end; end; SetLength(Result,PtrUInt(Dest)-PtrUInt(Result)); end; function UnicodeToCP1250(Unicode: cardinal): integer; begin case Unicode of 0..127: Result:=Unicode; 160: Result:=160; 164: Result:=164; 166..169: Result:=Unicode; 171..174: Result:=Unicode; 176..177: Result:=Unicode; 180..184: Result:=Unicode; 187: Result:=187; 193..194: Result:=Unicode; 196: Result:=196; 199: Result:=199; 201: Result:=201; 203: Result:=203; 205..206: Result:=Unicode; 211..212: Result:=Unicode; 214..215: Result:=Unicode; 218: Result:=218; 220..221: Result:=Unicode; 223: Result:=223; 225..226: Result:=Unicode; 228: Result:=228; 231: Result:=231; 233: Result:=233; 235: Result:=235; 237..238: Result:=Unicode; 243..244: Result:=Unicode; 246..247: Result:=Unicode; 250: Result:=250; 252..253: Result:=Unicode; 258: Result:=195; 259: Result:=227; 260: Result:=165; 261: Result:=185; 262: Result:=198; 263: Result:=230; 268: Result:=200; 269: Result:=232; 270: Result:=207; 271: Result:=239; 272: Result:=208; 273: Result:=240; 280: Result:=202; 281: Result:=234; 282: Result:=204; 283: Result:=236; 313: Result:=197; 314: Result:=229; 317: Result:=188; 318: Result:=190; 321: Result:=163; 322: Result:=179; 323: Result:=209; 324: Result:=241; 327: Result:=210; 328: Result:=242; 336: Result:=213; 337: Result:=245; 340: Result:=192; 341: Result:=224; 344: Result:=216; 345: Result:=248; 346: Result:=140; 347: Result:=156; 350: Result:=170; 351: Result:=186; 352: Result:=138; 353: Result:=154; 354: Result:=222; 355: Result:=254; 356: Result:=141; 357: Result:=157; 366: Result:=217; 367: Result:=249; 368: Result:=219; 369: Result:=251; 377: Result:=143; 378: Result:=159; 379: Result:=175; 380: Result:=191; 381: Result:=142; 382: Result:=158; 711: Result:=161; 728: Result:=162; 729: Result:=255; 731: Result:=178; 733: Result:=189; 8211..8212: Result:=Unicode-8061; 8216..8217: Result:=Unicode-8071; 8218: Result:=130; 8220..8221: Result:=Unicode-8073; 8222: Result:=132; 8224..8225: Result:=Unicode-8090; 8226: Result:=149; 8230: Result:=133; 8240: Result:=137; 8249: Result:=139; 8250: Result:=155; 8364: Result:=128; 8482: Result:=153; else Result:=-1; end; end; function UnicodeToCP1251(Unicode: cardinal): integer; begin case Unicode of 0..127: Result:=Unicode; 160: Result:=160; 164: Result:=164; 166..167: Result:=Unicode; 169: Result:=169; 171..174: Result:=Unicode; 176..177: Result:=Unicode; 181..183: Result:=Unicode; 187: Result:=187; 1025: Result:=168; 1026..1027: Result:=Unicode-898; 1028: Result:=170; 1029: Result:=189; 1030: Result:=178; 1031: Result:=175; 1032: Result:=163; 1033: Result:=138; 1034: Result:=140; 1035: Result:=142; 1036: Result:=141; 1038: Result:=161; 1039: Result:=143; 1040..1103: Result:=Unicode-848; 1105: Result:=184; 1106: Result:=144; 1107: Result:=131; 1108: Result:=186; 1109: Result:=190; 1110: Result:=179; 1111: Result:=191; 1112: Result:=188; 1113: Result:=154; 1114: Result:=156; 1115: Result:=158; 1116: Result:=157; 1118: Result:=162; 1119: Result:=159; 1168: Result:=165; 1169: Result:=180; 8211..8212: Result:=Unicode-8061; 8216..8217: Result:=Unicode-8071; 8218: Result:=130; 8220..8221: Result:=Unicode-8073; 8222: Result:=132; 8224..8225: Result:=Unicode-8090; 8226: Result:=149; 8230: Result:=133; 8240: Result:=137; 8249: Result:=139; 8250: Result:=155; 8364: Result:=136; 8470: Result:=185; 8482: Result:=153; else Result:=-1; end; end; function UnicodeToCP1252(Unicode: cardinal): integer; begin case Unicode of 0..127: Result:=Unicode; 160..255: Result:=Unicode; 338: Result:=140; 339: Result:=156; 352: Result:=138; 353: Result:=154; 376: Result:=159; 381: Result:=142; 382: Result:=158; 402: Result:=131; 710: Result:=136; 732: Result:=152; 8211..8212: Result:=Unicode-8061; 8216..8217: Result:=Unicode-8071; 8218: Result:=130; 8220..8221: Result:=Unicode-8073; 8222: Result:=132; 8224..8225: Result:=Unicode-8090; 8226: Result:=149; 8230: Result:=133; 8240: Result:=137; 8249: Result:=139; 8250: Result:=155; 8364: Result:=128; 8482: Result:=153; else Result:=-1; end; end; function UnicodeToCP1253(Unicode: cardinal): integer; begin case Unicode of 0..127: Result:=Unicode; 160: Result:=160; 163..169: Result:=Unicode; 171..174: Result:=Unicode; 176..179: Result:=Unicode; 181..183: Result:=Unicode; 187: Result:=187; 189: Result:=189; 402: Result:=131; 900: Result:=180; 901..902: Result:=Unicode-740; 904..906: Result:=Unicode-720; 908: Result:=188; 910..929: Result:=Unicode-720; 931..974: Result:=Unicode-720; 8211..8212: Result:=Unicode-8061; 8213: Result:=175; 8216..8217: Result:=Unicode-8071; 8218: Result:=130; 8220..8221: Result:=Unicode-8073; 8222: Result:=132; 8224..8225: Result:=Unicode-8090; 8226: Result:=149; 8230: Result:=133; 8240: Result:=137; 8249: Result:=139; 8250: Result:=155; 8364: Result:=128; 8482: Result:=153; else Result:=-1; end; end; function UnicodeToCP1254(Unicode: cardinal): integer; begin case Unicode of 0..127: Result:=Unicode; 160..207: Result:=Unicode; 209..220: Result:=Unicode; 223..239: Result:=Unicode; 241..252: Result:=Unicode; 255: Result:=255; 286: Result:=208; 287: Result:=240; 304: Result:=221; 305: Result:=253; 338: Result:=140; 339: Result:=156; 350: Result:=222; 351: Result:=254; 352: Result:=138; 353: Result:=154; 376: Result:=159; 402: Result:=131; 710: Result:=136; 732: Result:=152; 8211..8212: Result:=Unicode-8061; 8216..8217: Result:=Unicode-8071; 8218: Result:=130; 8220..8221: Result:=Unicode-8073; 8222: Result:=132; 8224..8225: Result:=Unicode-8090; 8226: Result:=149; 8230: Result:=133; 8240: Result:=137; 8249: Result:=139; 8250: Result:=155; 8364: Result:=128; 8482: Result:=153; else Result:=-1; end; end; function UnicodeToCP1255(Unicode: cardinal): integer; begin case Unicode of 0..127: Result:=Unicode; 160..163: Result:=Unicode; 165..169: Result:=Unicode; 171..185: Result:=Unicode; 187..191: Result:=Unicode; 215: Result:=170; 247: Result:=186; 402: Result:=131; 710: Result:=136; 732: Result:=152; 1456..1465: Result:=Unicode-1264; 1467..1475: Result:=Unicode-1264; 1488..1514: Result:=Unicode-1264; 1520..1524: Result:=Unicode-1308; 8206..8207: Result:=Unicode-7953; 8211..8212: Result:=Unicode-8061; 8216..8217: Result:=Unicode-8071; 8218: Result:=130; 8220..8221: Result:=Unicode-8073; 8222: Result:=132; 8224..8225: Result:=Unicode-8090; 8226: Result:=149; 8230: Result:=133; 8240: Result:=137; 8249: Result:=139; 8250: Result:=155; 8362: Result:=164; 8364: Result:=128; 8482: Result:=153; else Result:=-1; end; end; function UnicodeToCP1256(Unicode: cardinal): integer; begin case Unicode of 0..127: Result:=Unicode; 160: Result:=160; 162..169: Result:=Unicode; 171..185: Result:=Unicode; 187..190: Result:=Unicode; 215: Result:=215; 224: Result:=224; 226: Result:=226; 231..235: Result:=Unicode; 238..239: Result:=Unicode; 244: Result:=244; 247: Result:=247; 249: Result:=249; 251..252: Result:=Unicode; 338: Result:=140; 339: Result:=156; 402: Result:=131; 710: Result:=136; 1548: Result:=161; 1563: Result:=186; 1567: Result:=191; 1569..1590: Result:=Unicode-1376; 1591..1594: Result:=Unicode-1375; 1600..1603: Result:=Unicode-1380; 1604: Result:=225; 1605..1608: Result:=Unicode-1378; 1609..1610: Result:=Unicode-1373; 1611..1614: Result:=Unicode-1371; 1615..1616: Result:=Unicode-1370; 1617: Result:=248; 1618: Result:=250; 1657: Result:=138; 1662: Result:=129; 1670: Result:=141; 1672: Result:=143; 1681: Result:=154; 1688: Result:=142; 1705: Result:=152; 1711: Result:=144; 1722: Result:=159; 1726: Result:=170; 1729: Result:=192; 1746: Result:=255; 8204..8205: Result:=Unicode-8047; 8206..8207: Result:=Unicode-7953; 8211..8212: Result:=Unicode-8061; 8216..8217: Result:=Unicode-8071; 8218: Result:=130; 8220..8221: Result:=Unicode-8073; 8222: Result:=132; 8224..8225: Result:=Unicode-8090; 8226: Result:=149; 8230: Result:=133; 8240: Result:=137; 8249: Result:=139; 8250: Result:=155; 8364: Result:=128; 8482: Result:=153; else Result:=-1; end; end; function UnicodeToCP1257(Unicode: cardinal): integer; begin case Unicode of 0..127: Result:=Unicode; 160: Result:=160; 162..164: Result:=Unicode; 166..167: Result:=Unicode; 168: Result:=141; 169: Result:=169; 171..174: Result:=Unicode; 175: Result:=157; 176..183: Result:=Unicode; 184: Result:=143; 185: Result:=185; 187..190: Result:=Unicode; 196..197: Result:=Unicode; 198: Result:=175; 201: Result:=201; 211: Result:=211; 213..215: Result:=Unicode; 216: Result:=168; 220: Result:=220; 223: Result:=223; 228..229: Result:=Unicode; 230: Result:=191; 233: Result:=233; 243: Result:=243; 245..247: Result:=Unicode; 248: Result:=184; 252: Result:=252; 256: Result:=194; 257: Result:=226; 260: Result:=192; 261: Result:=224; 262: Result:=195; 263: Result:=227; 268: Result:=200; 269: Result:=232; 274: Result:=199; 275: Result:=231; 278: Result:=203; 279: Result:=235; 280: Result:=198; 281: Result:=230; 290: Result:=204; 291: Result:=236; 298: Result:=206; 299: Result:=238; 302: Result:=193; 303: Result:=225; 310: Result:=205; 311: Result:=237; 315: Result:=207; 316: Result:=239; 321: Result:=217; 322: Result:=249; 323: Result:=209; 324: Result:=241; 325: Result:=210; 326: Result:=242; 332: Result:=212; 333: Result:=244; 342: Result:=170; 343: Result:=186; 346: Result:=218; 347: Result:=250; 352: Result:=208; 353: Result:=240; 362: Result:=219; 363: Result:=251; 370: Result:=216; 371: Result:=248; 377: Result:=202; 378: Result:=234; 379: Result:=221; 380: Result:=253; 381: Result:=222; 382: Result:=254; 711: Result:=142; 729: Result:=255; 731: Result:=158; 8211..8212: Result:=Unicode-8061; 8216..8217: Result:=Unicode-8071; 8218: Result:=130; 8220..8221: Result:=Unicode-8073; 8222: Result:=132; 8224..8225: Result:=Unicode-8090; 8226: Result:=149; 8230: Result:=133; 8240: Result:=137; 8249: Result:=139; 8250: Result:=155; 8364: Result:=128; 8482: Result:=153; else Result:=-1; end; end; function UnicodeToCP1258(Unicode: cardinal): integer; begin case Unicode of 0..127: Result:=Unicode; 160..194: Result:=Unicode; 196..203: Result:=Unicode; 205..207: Result:=Unicode; 209: Result:=209; 211..212: Result:=Unicode; 214..220: Result:=Unicode; 223..226: Result:=Unicode; 228..235: Result:=Unicode; 237..239: Result:=Unicode; 241: Result:=241; 243..244: Result:=Unicode; 246..252: Result:=Unicode; 255: Result:=255; 258: Result:=195; 259: Result:=227; 272: Result:=208; 273: Result:=240; 338: Result:=140; 339: Result:=156; 376: Result:=159; 402: Result:=131; 416: Result:=213; 417: Result:=245; 431: Result:=221; 432: Result:=253; 710: Result:=136; 732: Result:=152; 768: Result:=204; 769: Result:=236; 771: Result:=222; 777: Result:=210; 803: Result:=242; 8211..8212: Result:=Unicode-8061; 8216..8217: Result:=Unicode-8071; 8218: Result:=130; 8220..8221: Result:=Unicode-8073; 8222: Result:=132; 8224..8225: Result:=Unicode-8090; 8226: Result:=149; 8230: Result:=133; 8240: Result:=137; 8249: Result:=139; 8250: Result:=155; 8363: Result:=254; 8364: Result:=128; 8482: Result:=153; else Result:=-1; end; end; function UnicodeToCP874(Unicode: cardinal): integer; begin case Unicode of 0..127: Result:=Unicode; 160: Result:=160; 3585..3642: Result:=Unicode-3424; 3647..3675: Result:=Unicode-3424; 8211..8212: Result:=Unicode-8061; 8216..8217: Result:=Unicode-8071; 8220..8221: Result:=Unicode-8073; 8226: Result:=149; 8230: Result:=133; 8364: Result:=128; else Result:=-1; end; end; function UnicodeToKOI8(Unicode: cardinal): integer; begin case Unicode of 0..127: Result:=Unicode; 1040..1041: Result:=Unicode-815; 1042: Result:=247; 1043: Result:=231; 1044..1045: Result:=Unicode-816; 1046: Result:=246; 1047: Result:=250; 1048..1055: Result:=Unicode-815; 1056..1059: Result:=Unicode-814; 1060: Result:=230; 1061: Result:=232; 1062: Result:=227; 1063: Result:=254; 1064: Result:=251; 1065: Result:=253; 1067: Result:=249; 1068: Result:=248; 1069: Result:=252; 1070: Result:=224; 1071: Result:=241; 1072..1073: Result:=Unicode-879; 1074: Result:=215; 1075: Result:=199; 1076..1077: Result:=Unicode-880; 1078: Result:=214; 1079: Result:=218; 1080..1087: Result:=Unicode-879; 1088..1091: Result:=Unicode-878; 1092: Result:=198; 1093: Result:=200; 1094: Result:=195; 1095: Result:=222; 1096: Result:=219; 1097: Result:=221; 1098: Result:=223; 1099: Result:=217; 1100: Result:=216; 1101: Result:=220; 1102: Result:=192; 1103: Result:=209; else Result:=-1; end; end; function UnicodeToISO_8859_1(Unicode: cardinal): integer; begin case Unicode of 0..255: Result:=Unicode; else Result:=-1; end; end; function UTF8ToISO_8859_1(const s: string): string; begin Result:=UTF8ToSingleByte(s,@UnicodeToISO_8859_1); end; function UTF8ToCP1250(const s: string): string; begin Result:=UTF8ToSingleByte(s,@UnicodeToCP1250); end; function UTF8ToCP1251(const s: string): string; begin Result:=UTF8ToSingleByte(s,@UnicodeToCP1251); end; function UTF8ToCP1252(const s: string): string; begin Result:=UTF8ToSingleByte(s,@UnicodeToCP1252); end; function UTF8ToCP1253(const s: string): string; begin Result:=UTF8ToSingleByte(s,@UnicodeToCP1253); end; function UTF8ToCP1254(const s: string): string; begin Result:=UTF8ToSingleByte(s,@UnicodeToCP1254); end; function UTF8ToCP1255(const s: string): string; begin Result:=UTF8ToSingleByte(s,@UnicodeToCP1255); end; function UTF8ToCP1256(const s: string): string; begin Result:=UTF8ToSingleByte(s,@UnicodeToCP1256); end; function UTF8ToCP1257(const s: string): string; begin Result:=UTF8ToSingleByte(s,@UnicodeToCP1257); end; function UTF8ToCP1258(const s: string): string; begin Result:=UTF8ToSingleByte(s,@UnicodeToCP1258); end; function UTF8ToCP874(const s: string): string; begin Result:=UTF8ToSingleByte(s,@UnicodeToCP874); end; function UTF8ToKOI8(const s: string): string; begin Result:=UTF8ToSingleByte(s,@UnicodeToKOI8); end; function UTF8ToSingleByte(const s: string; const UTF8CharConvFunc: TUnicodeToCharID): string; var len: Integer; Src: PChar; Dest: PChar; c: Char; Unicode: LongWord; CharLen: integer; i: integer; begin if s='' then begin Result:=''; exit; end; len:=length(s); SetLength(Result,len); Src:=PChar(s); Dest:=PChar(Result); while len>0 do begin c:=Src^; if c<#128 then begin Dest^:=c; inc(Dest); inc(Src); dec(len); end else begin Unicode:=UTF8CharacterToUnicode(Src,CharLen); inc(Src,CharLen); dec(len,CharLen); i:=UTF8CharConvFunc(Unicode); if i>=0 then begin Dest^:=chr(i); inc(Dest); end; end; end; SetLength(Result,Dest-PChar(Result)); end; procedure GetSupportedEncodings(List: TStrings); begin List.Add('UTF-8'); List.Add('Ansi'); List.Add('CP1250'); List.Add('CP1251'); List.Add('CP1252'); List.Add('CP1253'); List.Add('CP1254'); List.Add('CP1255'); List.Add('CP1256'); List.Add('CP1257'); List.Add('CP1258'); List.Add('CP874'); List.Add('ISO-8859-1'); end; function Utf2Cp1251(s:string):string; var i:integer; Skip,DSkip:boolean; begin //TODO Complete SystemEncoding conversion Skip:=false;DSkip:=false;Result:=''; for i:=1 to length(s) do begin if DSkip then begin Skip:=true;DSkip:=false;continue;end; if Skip then begin Skip:=false;Continue;end; if s[i]<#127 then begin Result:=Result+s[i];continue; end; if i=length(s) then break;//Do not translate 'strange' symbol if (s[i]=chr($D0)) and (s[i+1]>=chr($90))and (s[i+1]=chr($80))and (s[i+1]Chr2 then begin if Chr1 in [97..122] then dec(Chr1,32); if Chr2 in [97..122] then dec(Chr2,32); if Chr1<>Chr2 then exit(false); end; inc(p1); inc(p2); end; Result:=true; end; begin l:=length(s); if l=0 then begin Result:=''; exit; end; // try BOM (Byte Order Mark) if CompareI(@s[1],#$EF#$BB#$BF,3) then begin Result:=EncodingUTF8; exit; end; // try {%encoding eee} if CompareI(@s[1],'{%encoding ',11) then begin p:=12; while (p<=l) and (s[p] in [' ',#9]) do inc(p); EndPos:=p; while (EndPos<=l) and (not (s[EndPos] in ['}',' ',#9])) do inc(EndPos); Result:=NormalizeEncoding(copy(s,p,EndPos-p)); exit; end; // try UTF-8 (this includes ASCII) p:=1; while (p<=l) do begin if ord(s[p])<128 then begin // ASCII inc(p); end else begin i:=UTF8CharacterStrictLength(@s[p]); if i=0 then break; inc(p); end; end; if p>l then begin Result:=EncodingUTF8; exit; end; // use system encoding Result:=GetSystemEncoding; if NormalizeEncoding(Result)=EncodingUTF8 then begin // the system encoding is UTF-8, but it is not UTF-8 // use ISO-8859-1 instead. This encoding has a full 1:1 mapping to unicode, // so no character is lost during conversions. Result:='ISO-8859-1'; end; end; function ConvertEncoding(const s, FromEncoding, ToEncoding: string): string; var AFrom, ATo, SysEnc: String; {$ifdef Unix} SL: TStringList; FN1, FN2: String; {$endif} begin AFrom:=NormalizeEncoding(FromEncoding); ATo:=NormalizeEncoding(ToEncoding); SysEnc:=NormalizeEncoding(GetSystemEncoding); if AFrom=EncodingAnsi then AFrom:=SysEnc; if ATo=EncodingAnsi then ATo:=SysEnc; if AFrom=ATo then begin Result:=s; exit; end; //DebugLn(['ConvertEncoding ',AFrom,' ',ATo]); if (AFrom=EncodingUTF8) then begin if ATo='iso88591' then begin Result:=UTF8ToISO_8859_1(s); exit; end; if ATo='cp1250' then begin Result:=UTF8ToCP1250(s); exit; end; if ATo='cp1251' then begin Result:=UTF8ToCP1251(s); exit; end; if ATo='cp1252' then begin Result:=UTF8ToCP1252(s); exit; end; if ATo='cp1253' then begin Result:=UTF8ToCP1253(s); exit; end; if ATo='cp1254' then begin Result:=UTF8ToCP1254(s); exit; end; if ATo='cp1255' then begin Result:=UTF8ToCP1255(s); exit; end; if ATo='cp1256' then begin Result:=UTF8ToCP1256(s); exit; end; if ATo='cp1257' then begin Result:=UTF8ToCP1257(s); exit; end; if ATo='cp1258' then begin Result:=UTF8ToCP1258(s); exit; end; if ATo='cp874' then begin Result:=UTF8ToCP874(s); exit; end; if ATo='koi8' then begin Result:=UTF8ToKOI8(s); exit; end; if (ATo=SysEnc) and Assigned(ConvertUTF8ToAnsi) then begin Result:=ConvertUTF8ToAnsi(s); exit; end; end else if ATo=EncodingUTF8 then begin if AFrom='iso88591' then begin Result:=ISO_8859_1ToUTF8(s); exit; end; if AFrom='cp1250' then begin Result:=CP1250ToUTF8(s); exit; end; if AFrom='cp1251' then begin Result:=CP1251ToUTF8(s); exit; end; if AFrom='cp1252' then begin Result:=CP1252ToUTF8(s); exit; end; if AFrom='cp1253' then begin Result:=CP1253ToUTF8(s); exit; end; if AFrom='cp1254' then begin Result:=CP1254ToUTF8(s); exit; end; if AFrom='cp1255' then begin Result:=CP1255ToUTF8(s); exit; end; if AFrom='cp1256' then begin Result:=CP1256ToUTF8(s); exit; end; if AFrom='cp1257' then begin Result:=CP1257ToUTF8(s); exit; end; if AFrom='cp1258' then begin Result:=CP1258ToUTF8(s); exit; end; if AFrom='cp874' then begin Result:=CP874ToUTF8(s); exit; end; if AFrom='koi8' then begin Result:=KOI8ToUTF8(s); exit; end; if (AFrom=SysEnc) and Assigned(ConvertAnsiToUTF8) then begin Result:=ConvertAnsiToUTF8(s); exit; end; end; if (AFrom='utf8') then begin if ATo='cp1251' then begin Result:=utf2cp1251(s);exit;end; if ATo='koi8r' then begin Result:=cp1251ToKoi8r(utf2cp1251(s));exit;end; end; if (ATo='utf8') then begin if AFrom='cp1251' then begin Result:=Cp1251toUTF(s);exit;end; if AFrom='koi8r' then begin Result:=Cp1251toUTF(Koi8rToCP1251(s));exit;end; end; //Stupid code. Works anyway, but extra-slow {$ifdef Unix} DebugLn(['CPConvert NOTE: using slow iconv workaround to convert from ',AFrom,' to ',ATo]); SL:=TStringList.Create; SL.Text:=s; FN1:=GetTempFileName; SL.SaveToFile(FN1); FN2:=GetTempFileName; fpSystem('iconv -f '+FromEncoding+' -t '+ToEncoding+' '+FN1+' >'+FN2); SL.LoadFromFile(FN2); if SL.Text<>'' then Result:=SL.Text else Result:=s; DeleteFile(FN1); DeleteFile(FN2); {$endif} end; end.