diff options
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/fpg_base.pas | 2 | ||||
-rw-r--r-- | src/corelib/fpg_stringutils.pas | 281 |
2 files changed, 282 insertions, 1 deletions
diff --git a/src/corelib/fpg_base.pas b/src/corelib/fpg_base.pas index 70f3b306..e5bccf6d 100644 --- a/src/corelib/fpg_base.pas +++ b/src/corelib/fpg_base.pas @@ -90,6 +90,8 @@ type // For providing user feedback. No need to display backtrace information EfpGUIUserFeedbackException = class(EfpGUIException); + TfpgTextEncoding = (encUTF8, encCP437, encCP850, encCP866, encIBMGraph); + const diff --git a/src/corelib/fpg_stringutils.pas b/src/corelib/fpg_stringutils.pas index 1acd518e..5bace136 100644 --- a/src/corelib/fpg_stringutils.pas +++ b/src/corelib/fpg_stringutils.pas @@ -1,7 +1,7 @@ { fpGUI - Free Pascal GUI Toolkit - Copyright (C) 2006 - 2010 See the file AUTHORS.txt, included in this + Copyright (C) 2006 - 2013 See the file AUTHORS.txt, included in this distribution, for details of the copyright. See the file COPYING.modifiedLGPL, included in this distribution, @@ -58,10 +58,12 @@ function fpgTrimR(const AString, ATrim: TfpgString; ACaseSensitive: boolean = f // Encoding conversions function CP437ToUTF8(const s: string): TfpgString; // DOS central europe function CP850ToUTF8(const s: string): TfpgString; // DOS western europe +function CP866ToUTF8(const s: string): TfpgString; // DOS and Windows console's cyrillic function IBMGraphToUTF8(const s: string): TfpgString; // IBM PC / DOS http://www.unicode.org/Public/MAPPINGS/VENDORS/MISC/IBMGRAPH.TXT function IPFToUTF8(const s: string): TfpgString; // minor replacements to improve DocView output function SingleByteToUTF8(const s: string; const Table: TCharToUTF8Table): TfpgString; +function ConvertTextToUTF8(const AEncoding: TfpgTextEncoding; const AText: AnsiString): TfpgString; implementation @@ -935,6 +937,265 @@ const ); + ArrayCP866ToUTF8 : 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 + #32, //#32 + #33, //#33 + #34, //#34 + #35, //#35 + #36, //#36 + #37, //#37 + #38, //#38 + #39, //#39 + #40, //#40 + #41, //#41 + #42, //#42 + #43, //#43 + #44, //#44 + #45, //#45 + #46, //#46 + #47, //#47 + #48, //#48 + #49, //#49 + #50, //#50 + #51, //#51 + #52, //#52 + #53, //#53 + #54, //#54 + #55, //#55 + #56, //#56 + #57, //#57 + #58, //#58 + #59, //#59 + #60, //#60 + #61, //#61 + #62, //#62 + #63, //#63 + #64, //#64 + #65, //#65 + #66, //#66 + #67, //#67 + #68, //#68 + #69, //#69 + #70, //#70 + #71, //#71 + #72, //#72 + #73, //#73 + #74, //#74 + #75, //#75 + #76, //#76 + #77, //#77 + #78, //#78 + #79, //#79 + #80, //#80 + #81, //#81 + #82, //#82 + #83, //#83 + #84, //#84 + #85, //#85 + #86, //#86 + #87, //#87 + #88, //#88 + #89, //#89 + #90, //#90 + #91, //#91 + #92, //#92 + #93, //#93 + #94, //#94 + #95, //#95 + #96, //#96 + #97, //#97 + #98, //#98 + #99, //#99 + #100, //#100 + #101, //#101 + #102, //#102 + #103, //#103 + #104, //#104 + #105, //#105 + #106, //#106 + #107, //#107 + #108, //#108 + #109, //#109 + #110, //#110 + #111, //#111 + #112, //#112 + #113, //#113 + #114, //#114 + #115, //#115 + #116, //#116 + #117, //#117 + #118, //#118 + #119, //#119 + #120, //#120 + #121, //#121 + #122, //#122 + #123, //#123 + #124, //#124 + #125, //#125 + #126, //#126 + #127, //#127 + #208#144, //#128 + #208#145, //#129 + #208#146, //#130 + #208#147, //#131 + #208#148, //#132 + #208#149, //#133 + #208#150, //#134 + #208#151, //#135 + #208#152, //#136 + #208#153, //#137 + #208#154, //#138 + #208#155, //#139 + #208#156, //#140 + #208#157, //#141 + #208#158, //#142 + #208#159, //#143 + #208#160, //#144 + #208#161, //#145 + #208#162, //#146 + #208#163, //#147 + #208#164, //#148 + #208#165, //#149 + #208#166, //#150 + #208#167, //#151 + #208#168, //#152 + #208#169, //#153 + #208#170, //#154 + #208#171, //#155 + #208#172, //#156 + #208#173, //#157 + #208#174, //#158 + #208#175, //#159 + #208#176, //#160 + #208#177, //#161 + #208#178, //#162 + #208#179, //#163 + #208#180, //#164 + #208#181, //#165 + #208#182, //#166 + #208#183, //#167 + #208#184, //#168 + #208#185, //#169 + #208#186, //#170 + #208#187, //#171 + #208#188, //#172 + #208#189, //#173 + #208#190, //#174 + #208#191, //#175 + #226#150#145, //#176 + #226#150#146, //#177 + #226#150#147, //#178 + #226#148#130, //#179 + #226#148#164, //#180 + #226#149#161, //#181 + #226#149#162, //#182 + #226#149#150, //#183 + #226#149#149, //#184 + #226#149#163, //#185 + #226#149#145, //#186 + #226#149#151, //#187 + #226#149#157, //#188 + #226#149#156, //#189 + #226#149#155, //#190 + #226#148#144, //#191 + #226#148#148, //#192 + #226#148#180, //#193 + #226#148#172, //#194 + #226#148#156, //#195 + #226#148#128, //#196 + #226#148#188, //#197 + #226#149#158, //#198 + #226#149#159, //#199 + #226#149#154, //#200 + #226#149#148, //#201 + #226#149#169, //#202 + #226#149#166, //#203 + #226#149#160, //#204 + #226#149#144, //#205 + #226#149#172, //#206 + #226#149#167, //#207 + #226#149#168, //#208 + #226#149#164, //#209 + #226#149#165, //#210 + #226#149#153, //#211 + #226#149#152, //#212 + #226#149#146, //#213 + #226#149#147, //#214 + #226#149#171, //#215 + #226#149#170, //#216 + #226#148#152, //#217 + #226#148#140, //#218 + #226#150#136, //#219 + #226#150#132, //#220 + #226#150#140, //#221 + #226#150#144, //#222 + #226#150#128, //#223 + #209#128, //#224 + #209#129, //#225 + #209#130, //#226 + #209#131, //#227 + #209#132, //#228 + #209#133, //#229 + #209#134, //#230 + #209#135, //#231 + #209#136, //#232 + #209#137, //#233 + #209#138, //#234 + #209#139, //#235 + #209#140, //#236 + #209#141, //#237 + #209#142, //#238 + #209#143, //#239 + #208#129, //#240 + #209#145, //#241 + #208#132, //#242 + #209#148, //#243 + #208#135, //#244 + #209#151, //#245 + #208#142, //#246 + #209#158, //#247 + #194#176, //#248 + #226#136#153, //#249 + #194#183, //#250 + #226#136#154, //#251 + #226#132#150, //#252 + #194#164, //#253 + #226#150#160, //#254 + #194#160 //#255 + ); + ArrayIBMGraphToUTF8: TCharToUTF8Table = ( #0, // #0 @@ -1465,6 +1726,11 @@ begin Result := SingleByteToUTF8(s, ArrayCP850ToUTF8); end; +function CP866ToUTF8(const s: string): TfpgString; +begin + Result := SingleByteToUTF8(s, ArrayCP866ToUTF8); +end; + function IBMGraphToUTF8(const s: string): TfpgString; begin Result := SingleByteToUTF8(s, ArrayIBMGraphToUTF8); @@ -1539,6 +1805,19 @@ begin SetLength(Result, PtrUInt(Dest)-PtrUInt(Result)); end; +function ConvertTextToUTF8(const AEncoding: TfpgTextEncoding; const AText: AnsiString): TfpgString; +begin + case AEncoding of + encUTF8: Result := IPFToUTF8(AText); + encCP437: Result := CP437ToUTF8(AText); + encCP850: Result := CP850ToUTF8(AText); + encCP866: Result := CP866ToUTF8(AText); + encIBMGraph: Result := IBMGraphToUTF8(AText); + else + Result := IPFToUTF8(AText); + end; +end; + end. |