diff --git a/components/fpspreadsheet/examples/excel5demo/excel5write.lpi b/components/fpspreadsheet/examples/excel5demo/excel5write.lpi index 4875319c2..ee291b8a6 100644 --- a/components/fpspreadsheet/examples/excel5demo/excel5write.lpi +++ b/components/fpspreadsheet/examples/excel5demo/excel5write.lpi @@ -15,7 +15,7 @@ - + diff --git a/components/fpspreadsheet/examples/excel5demo/excel5write.lpr b/components/fpspreadsheet/examples/excel5demo/excel5write.lpr index 433d99fd0..f8e55b209 100644 --- a/components/fpspreadsheet/examples/excel5demo/excel5write.lpr +++ b/components/fpspreadsheet/examples/excel5demo/excel5write.lpr @@ -11,8 +11,16 @@ program excel5write; uses Classes, SysUtils, fpspreadsheet, xlsbiff5, - laz_fpspreadsheet; + laz_fpspreadsheet, fpsconvencoding; +const + Str_First = 'First'; + Str_Second = 'Second'; + Str_Third = 'Third'; + Str_Fourth = 'Fourth'; + Str_Worksheet1 = 'Meu Relatório'; + Str_Worksheet2 = 'My Worksheet 2'; + Str_Total = 'Total:'; var MyWorkbook: TsWorkbook; MyWorksheet: TsWorksheet; @@ -24,14 +32,14 @@ begin // Create the spreadsheet MyWorkbook := TsWorkbook.Create; - MyWorksheet := MyWorkbook.AddWorksheet('Meu Relatório'); + MyWorksheet := MyWorkbook.AddWorksheet(Str_Worksheet1); // Write some cells MyWorksheet.WriteNumber(0, 0, 1.0);// A1 MyWorksheet.WriteNumber(0, 1, 2.0);// B1 MyWorksheet.WriteNumber(0, 2, 3.0);// C1 MyWorksheet.WriteNumber(0, 3, 4.0);// D1 - MyWorksheet.WriteUTF8Text(4, 2, 'Total:');// C5 + MyWorksheet.WriteUTF8Text(4, 2, Str_Total);// C5 MyWorksheet.WriteNumber(4, 3, 10); // D5 { Uncommend this to test large XLS files @@ -66,13 +74,13 @@ begin //MyFormula.FormulaStr := ''; // Creates a new worksheet - MyWorksheet := MyWorkbook.AddWorksheet('My Worksheet 2'); + MyWorksheet := MyWorkbook.AddWorksheet(Str_Worksheet2); -{ // Write some string cells - MyWorksheet.WriteUTF8Text(0, 0, 'First'); - MyWorksheet.WriteUTF8Text(0, 1, 'Second'); - MyWorksheet.WriteUTF8Text(0, 2, 'Third'); - MyWorksheet.WriteUTF8Text(0, 3, 'Fourth');} + // Write some string cells + MyWorksheet.WriteUTF8Text(0, 0, Str_First); + MyWorksheet.WriteUTF8Text(0, 1, Str_Second); + MyWorksheet.WriteUTF8Text(0, 2, Str_Third); + MyWorksheet.WriteUTF8Text(0, 3, Str_Fourth); // Save the spreadsheet to a file MyWorkbook.WriteToFile(MyDir + 'test.xls', sfExcel5, False); diff --git a/components/fpspreadsheet/examples/excel8demo/excel8write.lpi b/components/fpspreadsheet/examples/excel8demo/excel8write.lpi new file mode 100644 index 000000000..a8b6f793b --- /dev/null +++ b/components/fpspreadsheet/examples/excel8demo/excel8write.lpi @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + <UseAppBundle Value="False"/> + </General> + <VersionInfo> + <StringTable Comments="" CompanyName="" FileDescription="" FileVersion="0.0.0.0" InternalName="" LegalCopyright="" LegalTrademarks="" OriginalFilename="" ProductName="" ProductVersion=""/> + </VersionInfo> + <PublishOptions> + <Version Value="2"/> + <IgnoreBinaries Value="False"/> + <IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/> + <ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/> + </PublishOptions> + <RunParams> + <local> + <FormatVersion Value="1"/> + <LaunchingApplication PathPlusParams="\usr\X11R6\bin\xterm -T 'Lazarus Run Output' -e $(LazarusDir)\tools\runwait.sh $(TargetCmdLine)"/> + </local> + </RunParams> + <RequiredPackages Count="1"> + <Item1> + <PackageName Value="laz_fpspreadsheet"/> + </Item1> + </RequiredPackages> + <Units Count="1"> + <Unit0> + <Filename Value="excel8write.lpr"/> + <IsPartOfProject Value="True"/> + <UnitName Value="excel8write"/> + </Unit0> + </Units> + </ProjectOptions> + <CompilerOptions> + <Version Value="8"/> + <PathDelim Value="\"/> + <SearchPaths> + <OtherUnitFiles Value="..\"/> + <SrcPath Value="..\"/> + </SearchPaths> + <Other> + <CompilerPath Value="$(CompPath)"/> + </Other> + </CompilerOptions> +</CONFIG> diff --git a/components/fpspreadsheet/examples/excel8demo/excel8write.lpr b/components/fpspreadsheet/examples/excel8demo/excel8write.lpr new file mode 100644 index 000000000..c0bb8a39a --- /dev/null +++ b/components/fpspreadsheet/examples/excel8demo/excel8write.lpr @@ -0,0 +1,90 @@ +{ +excel8write.dpr + +Demonstrates how to write an Excel 8+ file using the fpspreadsheet library + +AUTHORS: Felipe Monteiro de Carvalho +} +program excel8write; + +{$mode delphi}{$H+} + +uses + Classes, SysUtils, fpspreadsheet, xlsbiff8, + laz_fpspreadsheet, fpsconvencoding; + +const + Str_First = 'First'; + Str_Second = 'Second'; + Str_Third = 'Third'; + Str_Fourth = 'Fourth'; + Str_Worksheet1 = 'Meu Relatório'; + Str_Worksheet2 = 'My Worksheet 2'; + Str_Total = 'Total:'; +var + MyWorkbook: TsWorkbook; + MyWorksheet: TsWorksheet; + MyRPNFormula: TsRPNFormula; + MyDir: string; + i: Integer; +begin + MyDir := ExtractFilePath(ParamStr(0)); + + // Create the spreadsheet + MyWorkbook := TsWorkbook.Create; + MyWorksheet := MyWorkbook.AddWorksheet(Str_Worksheet1); + + // Write some cells + MyWorksheet.WriteNumber(0, 0, 1.0);// A1 + MyWorksheet.WriteNumber(0, 1, 2.0);// B1 + MyWorksheet.WriteNumber(0, 2, 3.0);// C1 + MyWorksheet.WriteNumber(0, 3, 4.0);// D1 + MyWorksheet.WriteUTF8Text(4, 2, Str_Total);// C5 + MyWorksheet.WriteNumber(4, 3, 10); // D5 + +{ Uncommend this to test large XLS files + for i := 2 to 20 do + begin + MyWorksheet.WriteAnsiText(i, 0, ParamStr(0)); + MyWorksheet.WriteAnsiText(i, 1, ParamStr(0)); + MyWorksheet.WriteAnsiText(i, 2, ParamStr(0)); + MyWorksheet.WriteAnsiText(i, 3, ParamStr(0)); + end; +} + + // Write the formula E1 = A1 + B1 + SetLength(MyRPNFormula, 3); + MyRPNFormula[0].ElementKind := fekCell; + MyRPNFormula[0].Col := 0; + MyRPNFormula[0].Row := 0; + MyRPNFormula[1].ElementKind := fekCell; + MyRPNFormula[1].Col := 1; + MyRPNFormula[1].Row := 0; + MyRPNFormula[2].ElementKind := fekAdd; + MyWorksheet.WriteRPNFormula(0, 4, MyRPNFormula); + + // Write the formula F1 = ABS(A1) + SetLength(MyRPNFormula, 2); + MyRPNFormula[0].ElementKind := fekCell; + MyRPNFormula[0].Col := 0; + MyRPNFormula[0].Row := 0; + MyRPNFormula[1].ElementKind := fekABS; + MyWorksheet.WriteRPNFormula(0, 5, MyRPNFormula); + + //MyFormula.FormulaStr := ''; + + // Creates a new worksheet + MyWorksheet := MyWorkbook.AddWorksheet(Str_Worksheet2); + + // Write some string cells + MyWorksheet.WriteUTF8Text(0, 0, Str_First); + MyWorksheet.WriteUTF8Text(0, 1, Str_Second); + MyWorksheet.WriteUTF8Text(0, 2, Str_Third); + MyWorksheet.WriteUTF8Text(0, 3, Str_Fourth); + MyWorksheet.WriteTextRotation(0, 0, rt90DegreeClockwiseRotation); + + // Save the spreadsheet to a file + MyWorkbook.WriteToFile(MyDir + 'test2.xls', sfExcel8, False); + MyWorkbook.Free; +end. + diff --git a/components/fpspreadsheet/fpsconvencoding.pas b/components/fpspreadsheet/fpsconvencoding.pas index 64b3de550..0fefaa0bf 100644 --- a/components/fpspreadsheet/fpsconvencoding.pas +++ b/components/fpspreadsheet/fpsconvencoding.pas @@ -1,16 +1,8 @@ -{ - ***************************************************************************** - * * - * This file is part of the Lazarus Component Library (LCL) * - * * - * See the file COPYING.modifiedLGPL.txt, 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. * - * * - ***************************************************************************** +{ 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; @@ -47,10 +39,28 @@ var 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; @@ -316,6 +326,2337 @@ const #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)); @@ -326,6 +2667,51 @@ 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 @@ -372,6 +2758,533 @@ begin 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; @@ -382,6 +3295,50 @@ 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; diff --git a/components/fpspreadsheet/fpsopendocument.pas b/components/fpspreadsheet/fpsopendocument.pas index a542544fd..072a1963e 100755 --- a/components/fpspreadsheet/fpsopendocument.pas +++ b/components/fpspreadsheet/fpsopendocument.pas @@ -71,7 +71,7 @@ type procedure WriteToStream(AStream: TStream; AData: TsWorkbook); override; { Record writing methods } procedure WriteFormula(AStream: TStream; const ARow, ACol: Word; const AFormula: TsFormula); override; - procedure WriteLabel(AStream: TStream; const ARow, ACol: Word; const AValue: string); override; + procedure WriteLabel(AStream: TStream; const ARow, ACol: Word; const AValue: string; ACell: PCell); override; procedure WriteNumber(AStream: TStream; const ARow, ACol: Cardinal; const AValue: double); override; end; @@ -537,7 +537,7 @@ begin end; procedure TsSpreadOpenDocWriter.WriteLabel(AStream: TStream; const ARow, - ACol: Word; const AValue: string); + ACol: Word; const AValue: string; ACell: PCell); begin // The row should already be the correct one FContent := FContent + diff --git a/components/fpspreadsheet/fpspreadsheet.pas b/components/fpspreadsheet/fpspreadsheet.pas index cfcaaad29..71c97bb88 100755 --- a/components/fpspreadsheet/fpspreadsheet.pas +++ b/components/fpspreadsheet/fpspreadsheet.pas @@ -14,7 +14,7 @@ unit fpspreadsheet; interface uses - Classes, SysUtils, AVL_Tree; + Classes, SysUtils, AVL_Tree, fpsconvencoding; type TsSpreadsheetFormat = (sfExcel2, sfExcel3, sfExcel4, sfExcel5, sfExcel8, @@ -28,6 +28,17 @@ const type + {@@ Possible encodings for a non-unicode encoded text } + TsEncoding = ( + seLatin1, + seLatin2, + seCyrillic, + seGreek, + seTurkish, + seHebrew, + seArabic + ); + {@@ Describes a formula Supported syntax: @@ -72,8 +83,22 @@ type {@@ Describes the type of content of a cell on a TsWorksheet } - TCellContentType = (cctEmpty, cctFormula, cctRPNFormula, cctNumber, cctUTF8String); - + TCellContentType = (cctEmpty, cctFormula, cctRPNFormula, cctNumber, + cctUTF8String); + + {@@ List of possible formatting fields } + + TsUsedFormattingField = (uffTextRotation); + + {@@ Describes which formatting fields are active } + + TsUsedFormattingFields = set of TsUsedFormattingField; + + {@@ Text rotation formatting} + + TsTextRotation = (trHorizontal, rt90DegreeClockwiseRotation, + rt90DegreeCounterClockwiseRotation); + {@@ Cell structure for TsWorksheet Never suppose that all *Value fields are valid, @@ -92,6 +117,9 @@ type RPNFormulaValue: TsRPNFormula; NumberValue: double; UTF8StringValue: ansistring; + { Formatting fields } + UsedFormattingFields: TsUsedFormattingFields; + TextRotation: TsTextRotation; end; PCell = ^TCell; @@ -128,6 +156,7 @@ type procedure WriteNumber(ARow, ACol: Cardinal; ANumber: double); procedure WriteFormula(ARow, ACol: Cardinal; AFormula: TsFormula); procedure WriteRPNFormula(ARow, ACol: Cardinal; AFormula: TsRPNFormula); + procedure WriteTextRotation(ARow, ACol: Cardinal; ARotation: TsTextRotation); property Cells: TAVLTree read FCells; end; @@ -137,6 +166,7 @@ type private { Internal data } FWorksheets: TFPList; + FEncoding: TsEncoding; { Internal methods } procedure RemoveCallback(data, arg: pointer); public @@ -157,6 +187,9 @@ type function GetWorksheetByIndex(AIndex: Cardinal): TsWorksheet; function GetWorksheetCount: Cardinal; procedure RemoveAllWorksheets; + {@@ This property is only used for formats which don't support unicode + and support a single encoding for the whole document, like Excel 2 to 5 } + property Encoding: TsEncoding read FEncoding write FEncoding; end; {@@ TsSpreadReader class reference type } @@ -198,7 +231,7 @@ type { Record writing methods } procedure WriteFormula(AStream: TStream; const ARow, ACol: Word; const AFormula: TsFormula); virtual; procedure WriteRPNFormula(AStream: TStream; const ARow, ACol: Word; const AFormula: TsRPNFormula); virtual; - procedure WriteLabel(AStream: TStream; const ARow, ACol: Word; const AValue: string); virtual; abstract; + procedure WriteLabel(AStream: TStream; const ARow, ACol: Word; const AValue: string; ACell: PCell); virtual; abstract; procedure WriteNumber(AStream: TStream; const ARow, ACol: Cardinal; const AValue: double); virtual; abstract; end; @@ -542,12 +575,12 @@ end; {@@ Writes UTF-8 encoded text to a determined cell. - On formats that only support unicode the text will be converted - to the unicode encoding that the format supports. + On formats that don't support unicode, the text will be converted + to ISO Latin 1. @param ARow The row of the cell @param ACol The column of the cell - @param AText The text to be written encoded with the system encoding + @param AText The text to be written encoded in utf-8 } procedure TsWorksheet.WriteUTF8Text(ARow, ACol: Cardinal; AText: ansistring); var @@ -604,6 +637,26 @@ begin ACell^.RPNFormulaValue := AFormula; end; +{@@ + Adds text rotation to the formatting of a cell + + @param ARow The row of the cell + @param ACol The column of the cell + @param ARotation How to rotate the text + + @see TsTextRotation +} +procedure TsWorksheet.WriteTextRotation(ARow, ACol: Cardinal; + ARotation: TsTextRotation); +var + ACell: PCell; +begin + ACell := GetCell(ARow, ACol); + + Include(ACell^.UsedFormattingFields, uffTextRotation); + ACell^.TextRotation := ARotation; +end; + { TsWorkbook } {@@ @@ -916,7 +969,7 @@ begin case ACell.ContentType of cctNumber: WriteNumber(AStream, ACell^.Row, ACell^.Col, ACell^.NumberValue); - cctUTF8String: WriteLabel(AStream, ACell^.Row, ACell^.Col, ACell^.UTF8StringValue); + cctUTF8String: WriteLabel(AStream, ACell^.Row, ACell^.Col, ACell^.UTF8StringValue, ACell); cctFormula: WriteFormula(AStream, ACell^.Row, ACell^.Col, ACell^.FormulaValue); cctRPNFormula: WriteRPNFormula(AStream, ACell^.Row, ACell^.Col, ACell^.RPNFormulaValue); end; diff --git a/components/fpspreadsheet/xlsbiff2.pas b/components/fpspreadsheet/xlsbiff2.pas index 544d0e012..f28e2f1f4 100755 --- a/components/fpspreadsheet/xlsbiff2.pas +++ b/components/fpspreadsheet/xlsbiff2.pas @@ -65,7 +65,7 @@ type procedure WriteBOF(AStream: TStream); procedure WriteEOF(AStream: TStream); procedure WriteRPNFormula(AStream: TStream; const ARow, ACol: Word; const AFormula: TsRPNFormula); override; - procedure WriteLabel(AStream: TStream; const ARow, ACol: Word; const AValue: string); override; + procedure WriteLabel(AStream: TStream; const ARow, ACol: Word; const AValue: string; ACell: PCell); override; procedure WriteNumber(AStream: TStream; const ARow, ACol: Cardinal; const AValue: double); override; end; @@ -279,7 +279,7 @@ end; * *******************************************************************} procedure TsSpreadBIFF2Writer.WriteLabel(AStream: TStream; const ARow, - ACol: Word; const AValue: string); + ACol: Word; const AValue: string; ACell: PCell); var L: Byte; AnsiText: ansistring; diff --git a/components/fpspreadsheet/xlsbiff5.pas b/components/fpspreadsheet/xlsbiff5.pas index 940b10673..a434e133d 100755 --- a/components/fpspreadsheet/xlsbiff5.pas +++ b/components/fpspreadsheet/xlsbiff5.pas @@ -103,6 +103,7 @@ type TsSpreadBIFF5Writer = class(TsCustomSpreadWriter) private + WorkBookEncoding: TsEncoding; function FEKindToExcelID(AElement: TFEKind; var AParamsNum: Byte; var AExtra: Word): Byte; public // constructor Create; @@ -114,12 +115,13 @@ type { Record writing methods } procedure WriteBOF(AStream: TStream; ADataType: Word); function WriteBoundsheet(AStream: TStream; ASheetName: string): Int64; + procedure WriteCodepage(AStream: TStream; AEncoding: TsEncoding); procedure WriteDimensions(AStream: TStream); procedure WriteEOF(AStream: TStream); procedure WriteFont(AStream: TStream; AFont: TFPCustomFont); procedure WriteRPNFormula(AStream: TStream; const ARow, ACol: Word; const AFormula: TsRPNFormula); override; procedure WriteIndex(AStream: TStream); - procedure WriteLabel(AStream: TStream; const ARow, ACol: Word; const AValue: string); override; + procedure WriteLabel(AStream: TStream; const ARow, ACol: Word; const AValue: string; ACell: PCell); override; procedure WriteNumber(AStream: TStream; const ARow, ACol: Cardinal; const AValue: double); override; procedure WriteStyle(AStream: TStream); procedure WriteWindow1(AStream: TStream); @@ -147,6 +149,7 @@ const INT_EXCEL_ID_RSTRING = $00D6; INT_EXCEL_ID_RK = $027E; INT_EXCEL_ID_MULRK = $00BD; + INT_EXCEL_ID_CODEPAGE = $0042; { Cell Addresses constants } MASK_EXCEL_ROW = $3FFF; @@ -164,9 +167,44 @@ const INT_BOF_BUILD_ID = $1FD2; INT_BOF_BUILD_YEAR = $07CD; + { CODEPAGE record constants } + + WORD_ASCII = 367; + WORD_UTF_16 = 1200; // BIFF 8 + WORD_CP_1250_Latin2 = 1250; + WORD_CP_1251_Cyrillic = 1251; + WORD_CP_1252_Latin1 = 1252; // BIFF4-BIFF5 + WORD_CP_1253_Greek = 1253; + WORD_CP_1254_Turkish = 1254; + WORD_CP_1255_Hebrew = 1255; + WORD_CP_1256_Arabic = 1256; + WORD_CP_1257_Baltic = 1257; + WORD_CP_1258_Vietnamese = 1258; + WORD_CP_1258_Latin1_BIFF2_3 = 32769; // BIFF2-BIFF3 + { FONT record constants } INT_FONT_WEIGHT_NORMAL = $0190; + BYTE_ANSILatin1 = $00; + BYTE_SYSTEM_DEFAULT = $01; + BYTE_SYMBOL = $02; + BYTE_Apple_Roman = $4D; + BYTE_ANSI_Japanese_Shift_JIS = $80; + BYTE_ANSI_Korean_Hangul = $81; + BYTE_ANSI_Korean_Johab = $81; + BYTE_ANSI_Chinese_Simplified_GBK = $86; + BYTE_ANSI_Chinese_Traditional_BIG5 = $88; + BYTE_ANSI_Greek = $A1; + BYTE_ANSI_Turkish = $A2; + BYTE_ANSI_Vietnamese = $A3; + BYTE_ANSI_Hebrew = $B1; + BYTE_ANSI_Arabic = $B2; + BYTE_ANSI_Baltic = $BA; + BYTE_ANSI_Cyrillic = $CC; + BYTE_ANSI_Thai = $DE; + BYTE_ANSI_Latin2 = $EE; + BYTE_OEM_Latin1 = $FF; + { FORMULA record constants } MASK_FORMULA_RECALCULATE_ALWAYS = $0001; MASK_FORMULA_RECALCULATE_ON_OPEN = $0002; @@ -318,10 +356,15 @@ var Boundsheets: array of Int64; i, len: Integer; begin + { Store some data about the workbook that other routines need } + WorkBookEncoding := AData.Encoding; + { Write workbook globals } WriteBOF(AStream, INT_BOF_WORKBOOK_GLOBALS); + WriteCodepage(AStream, WorkBookEncoding); + WriteWindow1(AStream); FontData := TFPCustomFont.Create; @@ -486,6 +529,29 @@ begin AStream.WriteBuffer(LatinSheetName[1], Len); end; +procedure TsSpreadBIFF5Writer.WriteCodepage(AStream: TStream; AEncoding: TsEncoding); +var + lCodepage: Word; +begin + { BIFF Record header } + AStream.WriteWord(WordToLE(INT_EXCEL_ID_CODEPAGE)); + AStream.WriteWord(WordToLE(2)); + + { Codepage } + case AEncoding of + seLatin2: lCodepage := WORD_CP_1250_Latin2; + seCyrillic: lCodepage := WORD_CP_1251_Cyrillic; + seGreek: lCodepage := WORD_CP_1253_Greek; + seTurkish: lCodepage := WORD_CP_1254_Turkish; + seHebrew: lCodepage := WORD_CP_1255_Hebrew; + seArabic: lCodepage := WORD_CP_1256_Arabic; + else + // Default is Latin1 + lCodepage := WORD_CP_1252_Latin1; + end; + AStream.WriteWord(WordToLE(lCodepage)); +end; + {******************************************************************* * TsSpreadBIFF5Writer.WriteIndex () * @@ -735,12 +801,23 @@ end; * *******************************************************************} procedure TsSpreadBIFF5Writer.WriteLabel(AStream: TStream; const ARow, - ACol: Word; const AValue: string); + ACol: Word; const AValue: string; ACell: PCell); var L: Word; AnsiValue: ansistring; begin - AnsiValue := UTF8ToISO_8859_1(AValue); + case WorkBookEncoding of + seLatin2: AnsiValue := UTF8ToCP1250(AValue); + seCyrillic: AnsiValue := UTF8ToCP1251(AValue); + seGreek: AnsiValue := UTF8ToCP1253(AValue); + seTurkish: AnsiValue := UTF8ToCP1254(AValue); + seHebrew: AnsiValue := UTF8ToCP1255(AValue); + seArabic: AnsiValue := UTF8ToCP1256(AValue); + else + // Latin 1 is the default + AnsiValue := UTF8ToCP1252(AValue); + end; + if AnsiValue = '' then begin // Bad formatted UTF8String (maybe ANSI?) diff --git a/components/fpspreadsheet/xlsbiff8.pas b/components/fpspreadsheet/xlsbiff8.pas index 2c4e03cae..6ba8fd067 100755 --- a/components/fpspreadsheet/xlsbiff8.pas +++ b/components/fpspreadsheet/xlsbiff8.pas @@ -114,15 +114,16 @@ type function WriteBoundsheet(AStream: TStream; ASheetName: string): Int64; procedure WriteDimensions(AStream: TStream); procedure WriteEOF(AStream: TStream); - procedure WriteFont(AStream: TStream; AFont: TFPCustomFont); + procedure WriteFont(AStream: TStream; AFont: TFPCustomFont); procedure WriteFormula(AStream: TStream; const ARow, ACol: Word; const AFormula: TsFormula); override; procedure WriteIndex(AStream: TStream); - procedure WriteLabel(AStream: TStream; const ARow, ACol: Word; const AValue: string); override; + procedure WriteLabel(AStream: TStream; const ARow, ACol: Word; const AValue: string; ACell: PCell); override; procedure WriteNumber(AStream: TStream; const ARow, ACol: Cardinal; const AValue: double); override; procedure WriteStyle(AStream: TStream); procedure WriteWindow1(AStream: TStream); procedure WriteWindow2(AStream: TStream; ASheetSelected: Boolean); - procedure WriteXF(AStream: TStream; AFontIndex: Word; AXF_TYPE_PROT: Byte); + procedure WriteXF(AStream: TStream; AFontIndex: Word; + AXF_TYPE_PROT, ATextRotation: Byte); end; implementation @@ -223,6 +224,12 @@ const MASK_XF_VERT_ALIGN_BOTTOM = $20; MASK_XF_VERT_ALIGN_JUSTIFIED = $30; + { XF_ROTATION } + + XF_ROTATION_HORIZONTAL = 0; + XF_ROTATION_90_DEGREE_COUNTERCLOCKWISE = 90; + XF_ROTATION_90_DEGREE_CLOCKWISE = 180; + { XF record constants } MASK_XF_TYPE_PROT = $0007; MASK_XF_TYPE_PROT_PARENT = $FFF0; @@ -314,37 +321,37 @@ begin end; // XF0 - WriteXF(AStream, 0, MASK_XF_TYPE_PROT_STYLE_XF); + WriteXF(AStream, 0, MASK_XF_TYPE_PROT_STYLE_XF, XF_ROTATION_HORIZONTAL); // XF1 - WriteXF(AStream, 0, MASK_XF_TYPE_PROT_STYLE_XF); + WriteXF(AStream, 0, MASK_XF_TYPE_PROT_STYLE_XF, XF_ROTATION_HORIZONTAL); // XF2 - WriteXF(AStream, 0, MASK_XF_TYPE_PROT_STYLE_XF); + WriteXF(AStream, 0, MASK_XF_TYPE_PROT_STYLE_XF, XF_ROTATION_HORIZONTAL); // XF3 - WriteXF(AStream, 0, MASK_XF_TYPE_PROT_STYLE_XF); + WriteXF(AStream, 0, MASK_XF_TYPE_PROT_STYLE_XF, XF_ROTATION_HORIZONTAL); // XF4 - WriteXF(AStream, 0, MASK_XF_TYPE_PROT_STYLE_XF); + WriteXF(AStream, 0, MASK_XF_TYPE_PROT_STYLE_XF, XF_ROTATION_HORIZONTAL); // XF5 - WriteXF(AStream, 0, MASK_XF_TYPE_PROT_STYLE_XF); + WriteXF(AStream, 0, MASK_XF_TYPE_PROT_STYLE_XF, XF_ROTATION_HORIZONTAL); // XF6 - WriteXF(AStream, 0, MASK_XF_TYPE_PROT_STYLE_XF); + WriteXF(AStream, 0, MASK_XF_TYPE_PROT_STYLE_XF, XF_ROTATION_HORIZONTAL); // XF7 - WriteXF(AStream, 0, MASK_XF_TYPE_PROT_STYLE_XF); + WriteXF(AStream, 0, MASK_XF_TYPE_PROT_STYLE_XF, XF_ROTATION_HORIZONTAL); // XF8 - WriteXF(AStream, 0, MASK_XF_TYPE_PROT_STYLE_XF); + WriteXF(AStream, 0, MASK_XF_TYPE_PROT_STYLE_XF, XF_ROTATION_HORIZONTAL); // XF9 - WriteXF(AStream, 0, MASK_XF_TYPE_PROT_STYLE_XF); + WriteXF(AStream, 0, MASK_XF_TYPE_PROT_STYLE_XF, XF_ROTATION_HORIZONTAL); // XF10 - WriteXF(AStream, 0, MASK_XF_TYPE_PROT_STYLE_XF); + WriteXF(AStream, 0, MASK_XF_TYPE_PROT_STYLE_XF, XF_ROTATION_HORIZONTAL); // XF11 - WriteXF(AStream, 0, MASK_XF_TYPE_PROT_STYLE_XF); + WriteXF(AStream, 0, MASK_XF_TYPE_PROT_STYLE_XF, XF_ROTATION_HORIZONTAL); // XF12 - WriteXF(AStream, 0, MASK_XF_TYPE_PROT_STYLE_XF); + WriteXF(AStream, 0, MASK_XF_TYPE_PROT_STYLE_XF, XF_ROTATION_HORIZONTAL); // XF13 - WriteXF(AStream, 0, MASK_XF_TYPE_PROT_STYLE_XF); + WriteXF(AStream, 0, MASK_XF_TYPE_PROT_STYLE_XF, XF_ROTATION_90_DEGREE_COUNTERCLOCKWISE); // XF14 - WriteXF(AStream, 0, MASK_XF_TYPE_PROT_STYLE_XF); + WriteXF(AStream, 0, MASK_XF_TYPE_PROT_STYLE_XF, XF_ROTATION_90_DEGREE_CLOCKWISE); // XF15 - WriteXF(AStream, 0, 0); + WriteXF(AStream, 0, 0, XF_ROTATION_HORIZONTAL); WriteStyle(AStream); @@ -696,7 +703,7 @@ end; * *******************************************************************} procedure TsSpreadBIFF8Writer.WriteLabel(AStream: TStream; const ARow, - ACol: Word; const AValue: string); + ACol: Word; const AValue: string; ACell: PCell); var L: Word; WideValue: WideString; @@ -721,8 +728,18 @@ begin AStream.WriteWord(WordToLE(ARow)); AStream.WriteWord(WordToLE(ACol)); - { Index to XF record } - AStream.WriteWord(WordToLE(15)); + { Index to XF record, according to formatting } + if ACell^.UsedFormattingFields = [uffTextRotation] then + begin + case ACell^.TextRotation of + rt90DegreeCounterClockwiseRotation: AStream.WriteWord(WordToLE(13)); + rt90DegreeClockwiseRotation: AStream.WriteWord(WordToLE(14)); + else + AStream.WriteWord(WordToLE(15)); + end; + end + else + AStream.WriteWord(WordToLE(15)); { Byte String with 16-bit size } AStream.WriteWord(WordToLE(L)); @@ -898,7 +915,7 @@ end; * *******************************************************************} procedure TsSpreadBIFF8Writer.WriteXF(AStream: TStream; AFontIndex: Word; - AXF_TYPE_PROT: Byte); + AXF_TYPE_PROT, ATextRotation: Byte); var XFOptions: Word; XFAlignment, XFOrientationAttrib: Byte; @@ -927,7 +944,7 @@ begin AStream.WriteByte(XFAlignment); { Text rotation } - AStream.WriteByte(0); + AStream.WriteByte(ATextRotation); // 0 is horizontal / normal { Indentation, shrink and text direction } AStream.WriteByte(0); diff --git a/components/fpspreadsheet/xlsxooxml.pas b/components/fpspreadsheet/xlsxooxml.pas index a22c19b48..ec185e6f4 100755 --- a/components/fpspreadsheet/xlsxooxml.pas +++ b/components/fpspreadsheet/xlsxooxml.pas @@ -63,7 +63,7 @@ type const AOverwriteExisting: Boolean = False); override; procedure WriteToStream(AStream: TStream; AData: TsWorkbook); override; { Record writing methods } - procedure WriteLabel(AStream: TStream; const ARow, ACol: Word; const AValue: string); override; + procedure WriteLabel(AStream: TStream; const ARow, ACol: Word; const AValue: string; ACell: PCell); override; procedure WriteNumber(AStream: TStream; const ARow, ACol: Cardinal; const AValue: double); override; end; @@ -382,7 +382,7 @@ end; Writes a string to the sheet } procedure TsSpreadOOXMLWriter.WriteLabel(AStream: TStream; const ARow, - ACol: Word; const AValue: string); + ACol: Word; const AValue: string; ACell: PCell); begin end;