LazUtils: Add encoding ISO-8859-10 to LConvEncoding. Issue #39800, patch by Alexey Torgashin.

This commit is contained in:
Juha 2022-06-20 09:59:08 +03:00
parent 748a44acdb
commit 3bea109b57
2 changed files with 329 additions and 0 deletions

View File

@ -533,6 +533,265 @@ const
#195#191 // #255
);
ArrayISO_8859_10ToUTF8: 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
#$C2#$A0, // $A0
#$C4#$84, // $A1
#$C4#$92, // $A2
#$C4#$A2, // $A3
#$C4#$AA, // $A4
#$C4#$A8, // $A5
#$C4#$B6, // $A6
#$C2#$A7, // $A7
#$C4#$BB, // $A8
#$C4#$90, // $A9
#$C5#$A0, // $AA
#$C5#$A6, // $AB
#$C5#$BD, // $AC
#$C2#$AD, // $AD
#$C5#$AA, // $AE
#$C5#$8A, // $AF
#$C2#$B0, // $B0
#$C4#$85, // $B1
#$C4#$93, // $B2
#$C4#$A3, // $B3
#$C4#$AB, // $B4
#$C4#$A9, // $B5
#$C4#$B7, // $B6
#$C2#$B7, // $B7
#$C4#$BC, // $B8
#$C4#$91, // $B9
#$C5#$A1, // $BA
#$C5#$A7, // $BB
#$C5#$BE, // $BC
#$E2#$80#$95, // $BD
#$C5#$AB, // $BE
#$C5#$8B, // $BF
#$C4#$80, // $C0
#$C3#$81, // $C1
#$C3#$82, // $C2
#$C3#$83, // $C3
#$C3#$84, // $C4
#$C3#$85, // $C5
#$C3#$86, // $C6
#$C4#$AE, // $C7
#$C4#$8C, // $C8
#$C3#$89, // $C9
#$C4#$98, // $CA
#$C3#$8B, // $CB
#$C4#$96, // $CC
#$C3#$8D, // $CD
#$C3#$8E, // $CE
#$C3#$8F, // $CF
#$C3#$90, // $D0
#$C5#$85, // $D1
#$C5#$8C, // $D2
#$C3#$93, // $D3
#$C3#$94, // $D4
#$C3#$95, // $D5
#$C3#$96, // $D6
#$C5#$A8, // $D7
#$C3#$98, // $D8
#$C5#$B2, // $D9
#$C3#$9A, // $DA
#$C3#$9B, // $DB
#$C3#$9C, // $DC
#$C3#$9D, // $DD
#$C3#$9E, // $DE
#$C3#$9F, // $DF
#$C4#$81, // $E0
#$C3#$A1, // $E1
#$C3#$A2, // $E2
#$C3#$A3, // $E3
#$C3#$A4, // $E4
#$C3#$A5, // $E5
#$C3#$A6, // $E6
#$C4#$AF, // $E7
#$C4#$8D, // $E8
#$C3#$A9, // $E9
#$C4#$99, // $EA
#$C3#$AB, // $EB
#$C4#$97, // $EC
#$C3#$AD, // $ED
#$C3#$AE, // $EE
#$C3#$AF, // $EF
#$C3#$B0, // $F0
#$C5#$86, // $F1
#$C5#$8D, // $F2
#$C3#$B3, // $F3
#$C3#$B4, // $F4
#$C3#$B5, // $F5
#$C3#$B6, // $F6
#$C5#$A9, // $F7
#$C3#$B8, // $F8
#$C5#$B3, // $F9
#$C3#$BA, // $FA
#$C3#$BB, // $FB
#$C3#$BC, // $FC
#$C3#$BD, // $FD
#$C3#$BE, // $FE
#$C4#$B8 // $FF
);
ArrayISO_8859_14ToUTF8: TCharToUTF8Table = (
#0, // #0
#1, // #1

View File

@ -81,6 +81,7 @@ const
EncodingCPIso2 = 'iso88592';
EncodingCPIso5 = 'iso88595';
EncodingCPIso9 = 'iso88599';
EncodingCPIso10 = 'iso885910';
EncodingCPIso14 = 'iso885914';
EncodingCPIso15 = 'iso885915';
EncodingCPIso16 = 'iso885916';
@ -130,6 +131,7 @@ function ISO_8859_1ToUTF8(const s: string): string; // central europe
function ISO_8859_2ToUTF8(const s: string): string; // eastern europe
function ISO_8859_5ToUTF8(const s: string): string; // Cyrillic
function ISO_8859_9ToUTF8(const s: string): string; // Turkish
function ISO_8859_10ToUTF8(const s: string): string;
function ISO_8859_14ToUTF8(const s: string): string;
function ISO_8859_15ToUTF8(const s: string): string; // Western European languages
function ISO_8859_16ToUTF8(const s: string): string;
@ -161,6 +163,7 @@ function UTF8ToISO_8859_1(const s: string; SetTargetCodePage: boolean = false):
function UTF8ToISO_8859_2(const s: string; SetTargetCodePage: boolean = false): RawByteString; // eastern europe
function UTF8ToISO_8859_5(const s: string; SetTargetCodePage: boolean = false): RawByteString; // Cyrillic
function UTF8ToISO_8859_9(const s: string; SetTargetCodePage: boolean = false): RawByteString; // Turkish
function UTF8ToISO_8859_10(const s: string; SetTargetCodePage: boolean = false): RawByteString;
function UTF8ToISO_8859_14(const s: string; SetTargetCodePage: boolean = false): RawByteString;
function UTF8ToISO_8859_15(const s: string; SetTargetCodePage: boolean = false): RawByteString; // Western European languages
function UTF8ToISO_8859_16(const s: string; SetTargetCodePage: boolean = false): RawByteString;
@ -388,6 +391,11 @@ begin
Result:=SingleByteToUTF8(s,ArrayISO_8859_9ToUTF8);
end;
function ISO_8859_10ToUTF8(const s: string): string;
begin
Result:=SingleByteToUTF8(s,ArrayISO_8859_10ToUTF8);
end;
function CP1250ToUTF8(const s: string): string;
begin
Result:=SingleByteToUTF8(s,ArrayCP1250ToUTF8);
@ -1137,6 +1145,60 @@ begin
end;
end;
function UnicodeToISO_8859_10(Unicode: cardinal): integer;
begin
case Unicode of
0..255: Result:= Unicode;
$104: Result:= $A1;
$112: Result:= $A2;
$122: Result:= $A3;
$12A: Result:= $A4;
$128: Result:= $A5;
$136: Result:= $A6;
$13B: Result:= $A8;
$110: Result:= $A9;
$160: Result:= $AA;
$166: Result:= $AB;
$17D: Result:= $AC;
$16A: Result:= $AE;
$14A: Result:= $AF;
$105: Result:= $B1;
$113: Result:= $B2;
$123: Result:= $B3;
$12B: Result:= $B4;
$129: Result:= $B5;
$137: Result:= $B6;
$13C: Result:= $B8;
$111: Result:= $B9;
$161: Result:= $BA;
$167: Result:= $BB;
$17E: Result:= $BC;
$2015: Result:= $BD;
$16B: Result:= $BE;
$14B: Result:= $BF;
$100: Result:= $C0;
$12E: Result:= $C7;
$10C: Result:= $C8;
$118: Result:= $CA;
$116: Result:= $CC;
$145: Result:= $D1;
$14C: Result:= $D2;
$168: Result:= $D7;
$172: Result:= $D9;
$101: Result:= $E0;
$12F: Result:= $E7;
$10D: Result:= $E8;
$119: Result:= $EA;
$117: Result:= $EC;
$146: Result:= $F1;
$14D: Result:= $F2;
$169: Result:= $F7;
$173: Result:= $F9;
$138: Result:= $FF;
else Result:=-1;
end;
end;
function UnicodeToISO_8859_14(Unicode: cardinal): integer;
begin
case Unicode of
@ -2128,6 +2190,11 @@ begin
InternalUTF8ToCP(s,28599,SetTargetCodePage,{$IfDef UseSystemCPConv}nil{$else}@UnicodeToISO_8859_9{$endif},Result);
end;
function UTF8ToISO_8859_10(const s: string; SetTargetCodePage: boolean): RawByteString;
begin
InternalUTF8ToCP(s,28600,SetTargetCodePage,{$IfDef UseSystemCPConv}nil{$else}@UnicodeToISO_8859_10{$endif},Result);
end;
function UTF8ToISO_8859_14(const s: string; SetTargetCodePage: boolean): RawByteString;
begin
InternalUTF8ToCP(s,28604,SetTargetCodePage,{$IfDef UseSystemCPConv}nil{$else}@UnicodeToISO_8859_14{$endif},Result);
@ -2397,6 +2464,7 @@ begin
List.Add('ISO-8859-2');
List.Add('ISO-8859-5');
List.Add('ISO-8859-9');
List.Add('ISO-8859-10');
List.Add('ISO-8859-14');
List.Add('ISO-8859-15');
List.Add('ISO-8859-16');
@ -2555,6 +2623,7 @@ begin
if ATo=EncodingCPIso2 then begin Result:=UTF8ToISO_8859_2(s,SetTargetCodePage); exit; end;
if ATo=EncodingCPIso5 then begin Result:=UTF8ToISO_8859_5(s,SetTargetCodePage); exit; end;
if ATo=EncodingCPIso9 then begin Result:=UTF8ToISO_8859_9(s,SetTargetCodePage); exit; end;
if ATo=EncodingCPIso10 then begin Result:=UTF8ToISO_8859_10(s,SetTargetCodePage); exit; end;
if ATo=EncodingCPIso14 then begin Result:=UTF8ToISO_8859_14(s,SetTargetCodePage); exit; end;
if ATo=EncodingCPIso15 then begin Result:=UTF8ToISO_8859_15(s,SetTargetCodePage); exit; end;
if ATo=EncodingCPIso16 then begin Result:=UTF8ToISO_8859_16(s,SetTargetCodePage); exit; end;
@ -2606,6 +2675,7 @@ begin
if AFrom=EncodingCPIso2 then begin Result:=ISO_8859_2ToUTF8(s); exit; end;
if AFrom=EncodingCPIso5 then begin Result:=ISO_8859_5ToUTF8(s); exit; end;
if AFrom=EncodingCPIso9 then begin Result:=ISO_8859_9ToUTF8(s); exit; end;
if AFrom=EncodingCPIso10 then begin Result:=ISO_8859_10ToUTF8(s); exit; end;
if AFrom=EncodingCPIso14 then begin Result:=ISO_8859_14ToUTF8(s); exit; end;
if AFrom=EncodingCPIso15 then begin Result:=ISO_8859_15ToUTF8(s); exit; end;
if AFrom=EncodingCPIso16 then begin Result:=ISO_8859_16ToUTF8(s); exit; end;