{ Code copied from lazarus/lcl/lconvencoding.pas This avoids adding the LCL as a dependency. Remove this unit once lconvencoding is in the FCL } unit fpsconvencoding; {$mode objfpc}{$H+} //{$IFDEF WINDOWS} //{$WARNING Windows/Wine/ReactOS locale conversion is not fully supported yet. Sorry.} //{$ENDIF} interface //{$IFNDEF DisableIconv} //{$IFDEF UNIX}{$IF not defined(VER2_2_0) and not defined(VER2_2_2)}{$DEFINE HasIconvEnc}{$ENDIF}{$ENDIF} //{$ENDIF} uses SysUtils, Classes, dos {$IFDEF HasIconvEnc},iconvenc{$ENDIF}; const EncodingUTF8 = 'utf8'; EncodingAnsi = 'ansi'; EncodingUTF8BOM = 'utf8bom'; // UTF-8 with byte order mark EncodingUCS2LE = 'ucs2le'; // UCS 2 byte little endian EncodingUCS2BE = 'ucs2le'; // UCS 2 byte big endian 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 SingleByteToUTF8(const s: string; const Table: TCharToUTF8Table): string; function UTF8BOMToUTF8(const s: string): string; // UTF8 with BOM 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 UTF8ToSingleByte(const s: string; const UTF8CharConvFunc: TUnicodeToCharID): 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 UTF8CharacterToUnicode(p: PChar; out CharLen: integer): Cardinal; implementation 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 ); function UTF8BOMToUTF8(const s: string): string; begin Result:=copy(s,4,length(s)); end; 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 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 UnicodeToISO_8859_1(Unicode: cardinal): integer; begin case Unicode of 0..255: Result:=Unicode; else Result:=-1; end; 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 UTF8ToUTF8BOM(const s: string): string; begin Result:=#$EF#$BB#$BF+s; 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 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('UTF-8BOM'); 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('CP866'); List.Add('CP874'); List.Add('ISO-8859-1'); List.Add('KOI-8'); List.Add('UCS-2LE'); List.Add('UCS-2BE'); end; function UTF8CharacterToUnicode(p: PChar; out CharLen: integer): Cardinal; begin if p<>nil then begin if ord(p^)<%11000000 then begin // regular single byte character (#0 is a normal char, this is pascal ;) Result:=ord(p^); CharLen:=1; end else if ((ord(p^) and %11100000) = %11000000) then begin // could be double byte character if (ord(p[1]) and %11000000) = %10000000 then begin Result:=((ord(p^) and %00011111) shl 6) or (ord(p[1]) and %00111111); CharLen:=2; end else begin Result:=ord(p^); CharLen:=1; end; end else if ((ord(p^) and %11110000) = %11100000) then begin // could be triple byte character if ((ord(p[1]) and %11000000) = %10000000) and ((ord(p[2]) and %11000000) = %10000000) then begin Result:=((ord(p^) and %00011111) shl 12) or ((ord(p[1]) and %00111111) shl 6) or (ord(p[2]) and %00111111); CharLen:=3; end else begin Result:=ord(p^); CharLen:=1; end; end else if ((ord(p^) and %11111000) = %11110000) then begin // could be 4 byte character if ((ord(p[1]) and %11000000) = %10000000) and ((ord(p[2]) and %11000000) = %10000000) and ((ord(p[3]) and %11000000) = %10000000) then begin Result:=((ord(p^) and %00001111) shl 18) or ((ord(p[1]) and %00111111) shl 12) or ((ord(p[2]) and %00111111) shl 6) or (ord(p[3]) and %00111111); CharLen:=4; end else begin Result:=ord(p^); CharLen:=1; end; end else begin // invalid character Result:=ord(p^); CharLen:=1; end; end else begin Result:=0; CharLen:=0; end; end; end.