sysstr.inc 52 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141
  1. {
  2. *********************************************************************
  3. $Id$
  4. Copyright (C) 1997, 1998 Gertjan Schouten
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. *********************************************************************
  17. System Utilities For Free Pascal
  18. }
  19. { NewStr creates a new PString and assigns S to it
  20. if length(s) = 0 NewStr returns Nil }
  21. function NewStr(const S: string): PString;
  22. begin
  23. if (S='') then
  24. Result:=nil
  25. else
  26. begin
  27. new(result);
  28. if (Result<>nil) then
  29. Result^:=s;
  30. end;
  31. end;
  32. { DisposeStr frees the memory occupied by S }
  33. procedure DisposeStr(S: PString);
  34. begin
  35. if S <> Nil then
  36. begin
  37. dispose(s);
  38. S:=nil;
  39. end;
  40. end;
  41. { AssignStr assigns S to P^ }
  42. procedure AssignStr(var P: PString; const S: string);
  43. begin
  44. P^ := s;
  45. end ;
  46. { AppendStr appends S to Dest }
  47. procedure AppendStr(var Dest: String; const S: string);
  48. begin
  49. Dest := Dest + S;
  50. end ;
  51. { UpperCase returns a copy of S where all lowercase characters ( from a to z )
  52. have been converted to uppercase }
  53. function UpperCase(const S: string): string;
  54. var i: integer;
  55. begin
  56. result := S;
  57. i := Length(S);
  58. while i <> 0 do begin
  59. if (result[i] in ['a'..'z']) then result[i] := char(byte(result[i]) - 32);
  60. Dec(i);
  61. end;
  62. end;
  63. { LowerCase returns a copy of S where all uppercase characters ( from A to Z )
  64. have been converted to lowercase }
  65. function LowerCase(const S: string): string;
  66. var i: integer;
  67. begin
  68. result := S;
  69. i := Length(result);
  70. while i <> 0 do begin
  71. if (result[i] in ['A'..'Z']) then result[i] := char(byte(result[i]) + 32);
  72. dec(i);
  73. end;
  74. end;
  75. { CompareStr compares S1 and S2, the result is the based on
  76. substraction of the ascii values of the characters in S1 and S2
  77. case result
  78. S1 < S2 < 0
  79. S1 > S2 > 0
  80. S1 = S2 = 0 }
  81. function CompareStr(const S1, S2: string): Integer;
  82. var count, count1, count2: integer;
  83. begin
  84. result := 0;
  85. Count1 := Length(S1);
  86. Count2 := Length(S2);
  87. if Count1>Count2 then
  88. Count:=Count2
  89. else
  90. Count:=Count1;
  91. result := CompareMemRange(Pointer(S1),Pointer(S2), Count);
  92. if result=0 then
  93. result:=Count1-Count2;
  94. end;
  95. { CompareMemRange returns the result of comparison of Length bytes at P1 and P2
  96. case result
  97. P1 < P2 < 0
  98. P1 > P2 > 0
  99. P1 = P2 = 0 }
  100. function CompareMemRange(P1, P2: Pointer; Length: cardinal): integer;
  101. var
  102. i: cardinal;
  103. begin
  104. i := 0;
  105. result := 0;
  106. while (result=0) and (I<length) do
  107. begin
  108. result:=byte(P1^)-byte(P2^);
  109. P1:=pchar(P1)+1; // VP compat.
  110. P2:=pchar(P2)+1;
  111. i := i + 1;
  112. end ;
  113. end ;
  114. function CompareMem(P1, P2: Pointer; Length: cardinal): Boolean;
  115. var
  116. i: cardinal;
  117. begin
  118. Result:=True;
  119. I:=0;
  120. If (P1)<>(P2) then
  121. While Result and (i<Length) do
  122. begin
  123. Result:=PByte(P1)^=PByte(P2)^;
  124. Inc(I);
  125. Inc(pchar(P1));
  126. Inc(pchar(P2));
  127. end;
  128. end;
  129. { CompareText compares S1 and S2, the result is the based on
  130. substraction of the ascii values of characters in S1 and S2
  131. comparison is case-insensitive
  132. case result
  133. S1 < S2 < 0
  134. S1 > S2 > 0
  135. S1 = S2 = 0 }
  136. function CompareText(const S1, S2: string): integer;
  137. var
  138. i, count, count1, count2: integer; Chr1, Chr2: byte;
  139. begin
  140. result := 0;
  141. Count1 := Length(S1);
  142. Count2 := Length(S2);
  143. if (Count1>Count2) then
  144. Count := Count2
  145. else
  146. Count := Count1;
  147. i := 0;
  148. while (result=0) and (i<count) do
  149. begin
  150. inc (i);
  151. Chr1 := byte(s1[i]);
  152. Chr2 := byte(s2[i]);
  153. if Chr1 in [97..122] then
  154. dec(Chr1,32);
  155. if Chr2 in [97..122] then
  156. dec(Chr2,32);
  157. result := Chr1 - Chr2;
  158. end ;
  159. if (result = 0) then
  160. result:=(count1-count2);
  161. end;
  162. function SameText(const s1,s2:String):Boolean;
  163. begin
  164. Result:=CompareText(S1,S2)=0;
  165. end;
  166. {==============================================================================}
  167. { Ansi string functions }
  168. { these functions rely on the character set loaded by the OS }
  169. {==============================================================================}
  170. function GenericAnsiUpperCase(const s: string): string;
  171. var
  172. len, i: integer;
  173. begin
  174. len := length(s);
  175. SetLength(result, len);
  176. for i := 1 to len do
  177. result[i] := UpperCaseTable[ord(s[i])];
  178. end;
  179. function GenericAnsiLowerCase(const s: string): string;
  180. var
  181. len, i: integer;
  182. begin
  183. len := length(s);
  184. SetLength(result, len);
  185. for i := 1 to len do
  186. result[i] := LowerCaseTable[ord(s[i])];
  187. end;
  188. function GenericAnsiCompareStr(const S1, S2: string): PtrInt;
  189. Var
  190. I,L1,L2 : SizeInt;
  191. begin
  192. Result:=0;
  193. L1:=Length(S1);
  194. L2:=Length(S2);
  195. I:=1;
  196. While (Result=0) and ((I<=L1) and (I<=L2)) do
  197. begin
  198. Result:=Ord(S1[I])-Ord(S2[I]); //!! Must be replaced by ansi characters !!
  199. Inc(I);
  200. end;
  201. If Result=0 Then
  202. Result:=L1-L2;
  203. end;
  204. function GenericAnsiCompareText(const S1, S2: string): PtrInt;
  205. Var
  206. I,L1,L2 : SizeInt;
  207. begin
  208. Result:=0;
  209. L1:=Length(S1);
  210. L2:=Length(S2);
  211. I:=1;
  212. While (Result=0) and ((I<=L1) and (I<=L2)) do
  213. begin
  214. Result:=Ord(LowerCaseTable[Ord(S1[I])])-Ord(LowerCaseTable[Ord(S2[I])]); //!! Must be replaced by ansi characters !!
  215. Inc(I);
  216. end;
  217. If Result=0 Then
  218. Result:=L1-L2;
  219. end;
  220. function AnsiSameText(const s1,s2:String):Boolean;{$ifdef SYSUTILSINLINE}inline;{$endif}
  221. begin
  222. AnsiSameText:=AnsiCompareText(S1,S2)=0;
  223. end;
  224. function AnsiSameStr(const s1,s2:String):Boolean;{$ifdef SYSUTILSINLINE}inline;{$endif}
  225. begin
  226. AnsiSameStr:=AnsiCompareStr(S1,S2)=0;
  227. end;
  228. function GenericAnsiStrComp(S1, S2: PChar): PtrInt;
  229. begin
  230. Result:=0;
  231. If S1=Nil then
  232. begin
  233. If S2=Nil Then Exit;
  234. result:=-1;
  235. exit;
  236. end;
  237. If S2=Nil then
  238. begin
  239. Result:=1;
  240. exit;
  241. end;
  242. Repeat
  243. Result:=Ord(S1[0])-Ord(S2[0]); //!! Must be replaced by ansi characters !!
  244. Inc(S1);
  245. Inc(S2);
  246. Until (Result<>0) or ((S1[0]=#0) or (S2[0]=#0))
  247. end;
  248. function GenericAnsiStrIComp(S1, S2: PChar): PtrInt;
  249. begin
  250. Result:=0;
  251. If S1=Nil then
  252. begin
  253. If S2=Nil Then Exit;
  254. result:=-1;
  255. exit;
  256. end;
  257. If S2=Nil then
  258. begin
  259. Result:=1;
  260. exit;
  261. end;
  262. Repeat
  263. Result:=Ord(LowerCaseTable[Ord(S1[0])])-Ord(LowerCaseTable[Ord(S2[0])]); //!! Must be replaced by ansi characters !!
  264. Inc(S1);
  265. Inc(S2);
  266. Until (Result<>0) or ((S1[0]=#0) or (S2[0]=#0))
  267. end;
  268. function GenericAnsiStrLComp(S1, S2: PChar; MaxLen: PtrUInt): PtrInt;
  269. Var I : cardinal;
  270. begin
  271. Result:=0;
  272. If MaxLen=0 then exit;
  273. If S1=Nil then
  274. begin
  275. If S2=Nil Then Exit;
  276. result:=-1;
  277. exit;
  278. end;
  279. If S2=Nil then
  280. begin
  281. Result:=1;
  282. exit;
  283. end;
  284. I:=0;
  285. Repeat
  286. Result:=Ord(S1[0])-Ord(S2[0]); //!! Must be replaced by ansi characters !!
  287. Inc(S1);
  288. Inc(S2);
  289. Inc(I);
  290. Until (Result<>0) or ((S1[0]=#0) or (S2[0]=#0)) or (I=MaxLen)
  291. end;
  292. function GenericAnsiStrLIComp(S1, S2: PChar; MaxLen: PtrUInt): PtrInt;
  293. Var I : cardinal;
  294. begin
  295. Result:=0;
  296. If MaxLen=0 then exit;
  297. If S1=Nil then
  298. begin
  299. If S2=Nil Then Exit;
  300. result:=-1;
  301. exit;
  302. end;
  303. If S2=Nil then
  304. begin
  305. Result:=1;
  306. exit;
  307. end;
  308. I:=0;
  309. Repeat
  310. Result:=Ord(LowerCaseTable[Ord(S1[0])])-Ord(LowerCaseTable[Ord(S2[0])]); //!! Must be replaced by ansi characters !!
  311. Inc(S1);
  312. Inc(S2);
  313. Inc(I);
  314. Until (Result<>0) or ((S1[0]=#0) or (S2[0]=#0)) or (I=MaxLen)
  315. end;
  316. function GenericAnsiStrLower(Str: PChar): PChar;
  317. begin
  318. result := Str;
  319. if Str <> Nil then begin
  320. while Str^ <> #0 do begin
  321. Str^ := LowerCaseTable[byte(Str^)];
  322. Str := Str + 1;
  323. end;
  324. end;
  325. end;
  326. function GenericAnsiStrUpper(Str: PChar): PChar;
  327. begin
  328. result := Str;
  329. if Str <> Nil then begin
  330. while Str^ <> #0 do begin
  331. Str^ := UpperCaseTable[byte(Str^)];
  332. Str := Str + 1;
  333. end ;
  334. end ;
  335. end ;
  336. function AnsiLastChar(const S: string): PChar;
  337. begin
  338. //!! No multibyte yet, so we return the last one.
  339. result:=StrEnd(Pchar(S));
  340. Dec(Result);
  341. end ;
  342. function AnsiStrLastChar(Str: PChar): PChar;
  343. begin
  344. //!! No multibyte yet, so we return the last one.
  345. result:=StrEnd(Str);
  346. Dec(Result);
  347. end ;
  348. function AnsiUpperCase(const s: string): string;{$ifdef SYSUTILSINLINE}inline;{$endif}
  349. begin
  350. {$ifndef ver1_0}
  351. result:=widestringmanager.UpperAnsiStringProc(s);
  352. {$endif}
  353. end;
  354. function AnsiLowerCase(const s: string): string;{$ifdef SYSUTILSINLINE}inline;{$endif}
  355. begin
  356. {$ifndef ver1_0}
  357. result:=widestringmanager.LowerAnsiStringProc(s);
  358. {$endif}
  359. end;
  360. function AnsiCompareStr(const S1, S2: string): integer;{$ifdef SYSUTILSINLINE}inline;{$endif}
  361. begin
  362. {$ifndef ver1_0}
  363. result:=widestringmanager.CompareStrAnsiStringProc(s1,s2);
  364. {$endif}
  365. end;
  366. function AnsiCompareText(const S1, S2: string): integer;{$ifdef SYSUTILSINLINE}inline;{$endif}
  367. begin
  368. {$ifndef ver1_0}
  369. result:=widestringmanager.CompareTextAnsiStringProc(s1,s2);
  370. {$endif}
  371. end;
  372. function AnsiStrComp(S1, S2: PChar): integer;{$ifdef SYSUTILSINLINE}inline;{$endif}
  373. begin
  374. {$ifndef ver1_0}
  375. result:=widestringmanager.StrCompAnsiStringProc(s1,s2);
  376. {$endif}
  377. end;
  378. function AnsiStrIComp(S1, S2: PChar): integer;{$ifdef SYSUTILSINLINE}inline;{$endif}
  379. begin
  380. {$ifndef ver1_0}
  381. result:=widestringmanager.StrICompAnsiStringProc(s1,s2);
  382. {$endif}
  383. end;
  384. function AnsiStrLComp(S1, S2: PChar; MaxLen: cardinal): integer;{$ifdef SYSUTILSINLINE}inline;{$endif}
  385. begin
  386. {$ifndef ver1_0}
  387. result:=widestringmanager.StrLCompAnsiStringProc(s1,s2,maxlen);
  388. {$endif}
  389. end;
  390. function AnsiStrLIComp(S1, S2: PChar; MaxLen: cardinal): integer;{$ifdef SYSUTILSINLINE}inline;{$endif}
  391. begin
  392. {$ifndef ver1_0}
  393. result:=widestringmanager.StrLICompAnsiStringProc(s1,s2,maxlen);
  394. {$endif}
  395. end;
  396. function AnsiStrLower(Str: PChar): PChar;{$ifdef SYSUTILSINLINE}inline;{$endif}
  397. begin
  398. {$ifndef ver1_0}
  399. result:=widestringmanager.StrLowerAnsiStringProc(Str);
  400. {$endif}
  401. end;
  402. function AnsiStrUpper(Str: PChar): PChar;{$ifdef SYSUTILSINLINE}inline;{$endif}
  403. begin
  404. {$ifndef ver1_0}
  405. result:=widestringmanager.StrUpperAnsiStringProc(Str);
  406. {$endif}
  407. end;
  408. {==============================================================================}
  409. { End of Ansi functions }
  410. {==============================================================================}
  411. { Trim returns a copy of S with blanks characters on the left and right stripped off }
  412. Const WhiteSpace = [' ',#10,#13,#9];
  413. function Trim(const S: string): string;
  414. var Ofs, Len: integer;
  415. begin
  416. len := Length(S);
  417. while (Len>0) and (S[Len] in WhiteSpace) do
  418. dec(Len);
  419. Ofs := 1;
  420. while (Ofs<=Len) and (S[Ofs] in WhiteSpace) do
  421. Inc(Ofs);
  422. result := Copy(S, Ofs, 1 + Len - Ofs);
  423. end ;
  424. { TrimLeft returns a copy of S with all blank characters on the left stripped off }
  425. function TrimLeft(const S: string): string;
  426. var i,l:integer;
  427. begin
  428. l := length(s);
  429. i := 1;
  430. while (i<=l) and (s[i] in whitespace) do
  431. inc(i);
  432. Result := copy(s, i, l);
  433. end ;
  434. { TrimRight returns a copy of S with all blank characters on the right stripped off }
  435. function TrimRight(const S: string): string;
  436. var l:integer;
  437. begin
  438. l := length(s);
  439. while (l>0) and (s[l] in whitespace) do
  440. dec(l);
  441. result := copy(s,1,l);
  442. end ;
  443. { QuotedStr returns S quoted left and right and every single quote in S
  444. replaced by two quotes }
  445. function QuotedStr(const S: string): string;
  446. begin
  447. result := AnsiQuotedStr(s, '''');
  448. end ;
  449. { AnsiQuotedStr returns S quoted left and right by Quote,
  450. and every single occurance of Quote replaced by two }
  451. function AnsiQuotedStr(const S: string; Quote: char): string;
  452. var i, j, count: integer;
  453. begin
  454. result := '' + Quote;
  455. count := length(s);
  456. i := 0;
  457. j := 0;
  458. while i < count do begin
  459. i := i + 1;
  460. if S[i] = Quote then begin
  461. result := result + copy(S, 1 + j, i - j) + Quote;
  462. j := i;
  463. end ;
  464. end ;
  465. if i <> j then
  466. result := result + copy(S, 1 + j, i - j);
  467. result := result + Quote;
  468. end ;
  469. { AnsiExtractQuotedStr returns a copy of Src with quote characters
  470. deleted to the left and right and double occurances
  471. of Quote replaced by a single Quote }
  472. function AnsiExtractQuotedStr(var Src: PChar; Quote: Char): string;
  473. var
  474. P,Q,R: PChar;
  475. begin
  476. P := Src;
  477. Q := StrEnd(P);
  478. result:='';
  479. if P=Q then exit;
  480. if P^<>quote then exit;
  481. inc(p);
  482. setlength(result,(Q-P)+1);
  483. R:=@Result[1];
  484. while P <> Q do
  485. begin
  486. R^:=P^;
  487. inc(R);
  488. if (P^ = Quote) then
  489. begin
  490. P := P + 1;
  491. if (p^ <> Quote) then
  492. begin
  493. dec(R);
  494. break;
  495. end;
  496. end;
  497. P := P + 1;
  498. end ;
  499. src:=p;
  500. SetLength(result, (R-pchar(@Result[1])));
  501. end ;
  502. { AdjustLineBreaks returns S with all CR characters not followed by LF
  503. replaced with CR/LF }
  504. // under Linux all CR characters or CR/LF combinations should be replaced with LF
  505. function AdjustLineBreaks(const S: string): string;
  506. begin
  507. Result:=AdjustLineBreaks(S,DefaultTextLineBreakStyle);
  508. end;
  509. function AdjustLineBreaks(const S: string; Style: TTextLineBreakStyle): string;
  510. var
  511. Source,Dest: PChar;
  512. DestLen: Integer;
  513. I,J,L: Longint;
  514. begin
  515. Source:=Pointer(S);
  516. L:=Length(S);
  517. DestLen:=L;
  518. I:=1;
  519. while (I<=L) do
  520. begin
  521. case S[i] of
  522. #10: if (Style=tlbsCRLF) then
  523. Inc(DestLen);
  524. #13: if (Style=tlbsCRLF) then
  525. if (I<L) and (S[i+1]=#10) then
  526. Inc(I)
  527. else
  528. Inc(DestLen)
  529. else if (I<L) and (S[I+1]=#10) then
  530. Dec(DestLen);
  531. end;
  532. Inc(I);
  533. end;
  534. if (DestLen=L) then
  535. Result:=S
  536. else
  537. begin
  538. SetLength(Result, DestLen);
  539. FillChar(Result[1],DestLen,0);
  540. Dest := Pointer(Result);
  541. J:=0;
  542. I:=0;
  543. While I<L do
  544. case Source[I] of
  545. #10: begin
  546. if Style=tlbsCRLF then
  547. begin
  548. Dest[j]:=#13;
  549. Inc(J);
  550. end;
  551. Dest[J] := #10;
  552. Inc(J);
  553. Inc(I);
  554. end;
  555. #13: begin
  556. if Style=tlbsCRLF then
  557. begin
  558. Dest[j] := #13;
  559. Inc(J);
  560. end;
  561. Dest[j]:=#10;
  562. Inc(J);
  563. Inc(I);
  564. if Source[I]=#10 then
  565. Inc(I);
  566. end;
  567. else
  568. Dest[j]:=Source[i];
  569. Inc(J);
  570. Inc(I);
  571. end;
  572. end;
  573. end;
  574. { IsValidIdent returns true if the first character of Ident is in:
  575. 'A' to 'Z', 'a' to 'z' or '_' and the following characters are
  576. on of: 'A' to 'Z', 'a' to 'z', '0'..'9' or '_' }
  577. function IsValidIdent(const Ident: string): boolean;
  578. var i, len: integer;
  579. begin
  580. result := false;
  581. len := length(Ident);
  582. if len <> 0 then begin
  583. result := Ident[1] in ['A'..'Z', 'a'..'z', '_'];
  584. i := 1;
  585. while (result) and (i < len) do begin
  586. i := i + 1;
  587. result := result and (Ident[i] in ['A'..'Z', 'a'..'z', '0'..'9', '_']);
  588. end ;
  589. end ;
  590. end ;
  591. { IntToStr returns a string representing the value of Value }
  592. function IntToStr(Value: integer): string;
  593. begin
  594. System.Str(Value, result);
  595. end ;
  596. {$IFNDEF VIRTUALPASCAL}
  597. function IntToStr(Value: int64): string;
  598. begin
  599. System.Str(Value, result);
  600. end ;
  601. {$ENDIF}
  602. function IntToStr(Value: QWord): string;
  603. begin
  604. System.Str(Value, result);
  605. end ;
  606. { IntToHex returns a string representing the hexadecimal value of Value }
  607. const
  608. HexDigits: array[0..15] of char = '0123456789ABCDEF';
  609. function IntToHex(Value: integer; Digits: integer): string;
  610. var i: integer;
  611. begin
  612. SetLength(result, digits);
  613. for i := 0 to digits - 1 do
  614. begin
  615. result[digits - i] := HexDigits[value and 15];
  616. value := value shr 4;
  617. end ;
  618. while value <> 0 do begin
  619. result := HexDigits[value and 15] + result;
  620. value := value shr 4;
  621. end;
  622. end ;
  623. {$IFNDEF VIRTUALPASCAL} // overloading
  624. function IntToHex(Value: int64; Digits: integer): string;
  625. var i: integer;
  626. begin
  627. SetLength(result, digits);
  628. for i := 0 to digits - 1 do
  629. begin
  630. result[digits - i] := HexDigits[value and 15];
  631. value := value shr 4;
  632. end ;
  633. while value <> 0 do begin
  634. result := HexDigits[value and 15] + result;
  635. value := value shr 4;
  636. end;
  637. end ;
  638. {$ENDIF}
  639. function TryStrToInt(const s: string; var i : integer) : boolean;
  640. var Error : word;
  641. begin
  642. Val(s, i, Error);
  643. TryStrToInt:=Error=0
  644. end;
  645. { StrToInt converts the string S to an integer value,
  646. if S does not represent a valid integer value EConvertError is raised }
  647. function StrToInt(const S: string): integer;
  648. {$IFDEF VIRTUALPASCAL}
  649. var Error: longint;
  650. {$ELSE}
  651. var Error: word;
  652. {$ENDIF}
  653. begin
  654. Val(S, result, Error);
  655. if Error <> 0 then raise EConvertError.createfmt(SInValidInteger,[S]);
  656. end ;
  657. function StrToInt64(const S: string): int64;
  658. {$IFDEF VIRTUALPASCAL}
  659. var Error: longint;
  660. {$ELSE}
  661. var Error: word;
  662. {$ENDIF}
  663. begin
  664. Val(S, result, Error);
  665. if Error <> 0 then raise EConvertError.createfmt(SInValidInteger,[S]);
  666. end;
  667. function TryStrToInt64(const s: string; var i : int64) : boolean;
  668. var Error : word;
  669. begin
  670. Val(s, i, Error);
  671. TryStrToInt64:=Error=0
  672. end;
  673. { StrToIntDef converts the string S to an integer value,
  674. Default is returned in case S does not represent a valid integer value }
  675. function StrToIntDef(const S: string; Default: integer): integer;
  676. {$IFDEF VIRTUALPASCAL}
  677. var Error: longint;
  678. {$ELSE}
  679. var Error: word;
  680. {$ENDIF}
  681. begin
  682. Val(S, result, Error);
  683. if Error <> 0 then result := Default;
  684. end ;
  685. { StrToIntDef converts the string S to an integer value,
  686. Default is returned in case S does not represent a valid integer value }
  687. function StrToInt64Def(const S: string; Default: int64): int64;
  688. {$IFDEF VIRTUALPASCAL}
  689. var Error: longint;
  690. {$ELSE}
  691. var Error: word;
  692. {$ENDIF}
  693. begin
  694. Val(S, result, Error);
  695. if Error <> 0 then result := Default;
  696. end ;
  697. { LoadStr returns the string resource Ident. }
  698. function LoadStr(Ident: integer): string;
  699. begin
  700. result:='';
  701. end ;
  702. { FmtLoadStr returns the string resource Ident and formats it accordingly }
  703. function FmtLoadStr(Ident: integer; const Args: array of const): string;
  704. begin
  705. result:='';
  706. end;
  707. Const
  708. feInvalidFormat = 1;
  709. feMissingArgument = 2;
  710. feInvalidArgIndex = 3;
  711. {$ifdef fmtdebug}
  712. Procedure Log (Const S: String);
  713. begin
  714. Writeln (S);
  715. end;
  716. {$endif}
  717. Procedure DoFormatError (ErrCode : Longint);
  718. Var
  719. S : String;
  720. begin
  721. //!! must be changed to contain format string...
  722. S:='';
  723. Case ErrCode of
  724. feInvalidFormat : raise EConvertError.Createfmt(SInvalidFormat,[s]);
  725. feMissingArgument : raise EConvertError.Createfmt(SArgumentMissing,[s]);
  726. feInvalidArgIndex : raise EConvertError.Createfmt(SInvalidArgIndex,[s]);
  727. end;
  728. end;
  729. { we've no templates, but with includes we can simulate this :) }
  730. {$macro on}
  731. {$define INFORMAT}
  732. {$define TFormatString:=ansistring}
  733. {$define TFormatChar:=char}
  734. Function Format (Const Fmt : AnsiString; const Args : Array of const) : AnsiString;
  735. {$i sysformt.inc}
  736. {$undef TFormatString}
  737. {$undef TFormatChar}
  738. {$undef INFORMAT}
  739. {$macro off}
  740. Function FormatBuf (Var Buffer; BufLen : Cardinal;
  741. Const Fmt; fmtLen : Cardinal;
  742. Const Args : Array of const) : Cardinal;
  743. Var S,F : String;
  744. begin
  745. Setlength(F,fmtlen);
  746. if fmtlen > 0 then
  747. Move(fmt,F[1],fmtlen);
  748. S:=Format (F,Args);
  749. If Cardinal(Length(S))<Buflen then
  750. Result:=Length(S)
  751. else
  752. Result:=Buflen;
  753. Move(S[1],Buffer,Result);
  754. end;
  755. Procedure FmtStr(Var Res: String; Const Fmt : String; Const args: Array of const);
  756. begin
  757. Res:=Format(fmt,Args);
  758. end;
  759. Function StrFmt(Buffer,Fmt : PChar; Const args: Array of const) : Pchar;
  760. begin
  761. Buffer[FormatBuf(Buffer^,Maxint,Fmt^,strlen(fmt),args)]:=#0;
  762. Result:=Buffer;
  763. end;
  764. Function StrLFmt(Buffer : PCHar; Maxlen : Cardinal;Fmt : PChar; Const args: Array of const) : Pchar;
  765. begin
  766. Buffer[FormatBuf(Buffer^,MaxLen,Fmt^,strlen(fmt),args)]:=#0;
  767. Result:=Buffer;
  768. end;
  769. Function StrToFloat(Const S: String): Extended;
  770. Begin
  771. If Not TextToFloat(Pchar(S),Result) then
  772. Raise EConvertError.createfmt(SInValidFLoat,[S]);
  773. End;
  774. function StrToFloatDef(const S: string; const Default: Extended): Extended;
  775. begin
  776. if not TextToFloat(PChar(S),Result,fvExtended) then
  777. Result:=Default;
  778. end;
  779. Function TextToFloat(Buffer: PChar; Var Value: Extended): Boolean;
  780. Var
  781. E,P : Integer;
  782. S : String;
  783. Begin
  784. S:=StrPas(Buffer);
  785. P:=Pos(DecimalSeparator,S);
  786. If (P<>0) Then
  787. S[P] := '.';
  788. Val(trim(S),Value,E);
  789. Result:=(E=0);
  790. End;
  791. Function TextToFloat(Buffer: PChar; Var Value; ValueType: TFloatValue): Boolean;
  792. Var
  793. E,P : Integer;
  794. S : String;
  795. Begin
  796. S:=StrPas(Buffer);
  797. P:=Pos(ThousandSeparator,S);
  798. While (P<>0) do
  799. begin
  800. Delete(S,P,1);
  801. P:=Pos(ThousandSeparator,S);
  802. end;
  803. P:=Pos(DecimalSeparator,S);
  804. If (P<>0) Then
  805. S[P] := '.';
  806. case ValueType of
  807. fvCurrency:
  808. Val(S,Currency(Value),E);
  809. fvExtended:
  810. Val(S,Extended(Value),E);
  811. fvDouble:
  812. Val(S,Double(Value),E);
  813. fvSingle:
  814. Val(S,Single(Value),E);
  815. fvComp:
  816. Val(S,Comp(Value),E);
  817. fvReal:
  818. Val(S,Real(Value),E);
  819. end;
  820. Result:=(E=0);
  821. End;
  822. Function TryStrToFloat(Const S : String; Var Value: Single): Boolean;
  823. Begin
  824. Result := TextToFloat(PChar(S), Value, fvSingle);
  825. End;
  826. Function TryStrToFloat(Const S : String; Var Value: Double): Boolean;
  827. Begin
  828. Result := TextToFloat(PChar(S), Value, fvDouble);
  829. End;
  830. {$ifdef FPC_HAS_TYPE_EXTENDED}
  831. Function TryStrToFloat(Const S : String; Var Value: Extended): Boolean;
  832. Begin
  833. Result := TextToFloat(PChar(S), Value);
  834. End;
  835. {$endif FPC_HAS_TYPE_EXTENDED}
  836. Function FloatToStr(Value: Extended): String;
  837. Begin
  838. Result := FloatToStrF(Value, ffGeneral, 15, 0);
  839. End;
  840. Function FloatToText(Buffer: PChar; Value: Extended; format: TFloatFormat; Precision, Digits: Integer): Longint;
  841. Var
  842. Tmp: String[40];
  843. Begin
  844. Tmp := FloatToStrF(Value, format, Precision, Digits);
  845. Result := Length(Tmp);
  846. Move(Tmp[1], Buffer[0], Result);
  847. End;
  848. Function FloatToStrF(Value: Extended; format: TFloatFormat; Precision, Digits: Integer): String;
  849. Var
  850. P: Integer;
  851. Negative, TooSmall, TooLarge: Boolean;
  852. Begin
  853. Case format Of
  854. ffGeneral:
  855. Begin
  856. If (Precision = -1) Or (Precision > 15) Then Precision := 15;
  857. TooSmall := (Abs(Value) < 0.00001) and (Value>0.0);
  858. If Not TooSmall Then
  859. Begin
  860. Str(Value:digits:precision, Result);
  861. P := Pos('.', Result);
  862. Result[P] := DecimalSeparator;
  863. TooLarge := P > Precision + 1;
  864. End;
  865. If TooSmall Or TooLarge Then
  866. begin
  867. Result := FloatToStrF(Value, ffExponent, Precision, Digits);
  868. // Strip unneeded zeroes.
  869. P:=Pos('E',result)-1;
  870. If P<>-1 then
  871. While (P>1) and (Result[P]='0') do
  872. begin
  873. system.Delete(Result,P,1);
  874. Dec(P);
  875. end;
  876. end
  877. else
  878. begin
  879. P := Length(Result);
  880. While Result[P] = '0' Do Dec(P);
  881. If Result[P] = DecimalSeparator Then Dec(P);
  882. SetLength(Result, P);
  883. end;
  884. End;
  885. ffExponent:
  886. Begin
  887. If (Precision = -1) Or (Precision > 15) Then Precision := 15;
  888. Str(Value:Precision + 8, Result);
  889. Result[3] := DecimalSeparator;
  890. P:=4;
  891. While (P>0) and (Digits < P) And (Result[Precision + 5] = '0') do
  892. Begin
  893. If P<>1 then
  894. system.Delete(Result, Precision + 5, 1)
  895. else
  896. system.Delete(Result, Precision + 3, 3);
  897. Dec(P);
  898. end;
  899. If Result[1] = ' ' Then
  900. System.Delete(Result, 1, 1);
  901. End;
  902. ffFixed:
  903. Begin
  904. If Digits = -1 Then Digits := 2
  905. Else If Digits > 18 Then Digits := 18;
  906. Str(Value:0:Digits, Result);
  907. If Result[1] = ' ' Then
  908. System.Delete(Result, 1, 1);
  909. P := Pos('.', Result);
  910. If P <> 0 Then Result[P] := DecimalSeparator;
  911. End;
  912. ffNumber:
  913. Begin
  914. If Digits = -1 Then Digits := 2
  915. Else If Digits > 15 Then Digits := 15;
  916. Str(Value:0:Digits, Result);
  917. If Result[1] = ' ' Then System.Delete(Result, 1, 1);
  918. P := Pos('.', Result);
  919. If P <> 0 Then
  920. Result[P] := DecimalSeparator
  921. else
  922. P := Length(Result)+1;
  923. Dec(P, 3);
  924. While (P > 1) Do
  925. Begin
  926. If Result[P - 1] <> '-' Then Insert(ThousandSeparator, Result, P);
  927. Dec(P, 3);
  928. End;
  929. End;
  930. ffCurrency:
  931. Begin
  932. If Value < 0 Then
  933. Begin
  934. Negative := True;
  935. Value := -Value;
  936. End
  937. Else Negative := False;
  938. If Digits = -1 Then Digits := CurrencyDecimals
  939. Else If Digits > 18 Then Digits := 18;
  940. Str(Value:0:Digits, Result);
  941. If Result[1] = ' ' Then System.Delete(Result, 1, 1);
  942. P := Pos('.', Result);
  943. If P <> 0 Then Result[P] := DecimalSeparator;
  944. Dec(P, 3);
  945. While (P > 1) Do
  946. Begin
  947. Insert(ThousandSeparator, Result, P);
  948. Dec(P, 3);
  949. End;
  950. If Not Negative Then
  951. Begin
  952. Case CurrencyFormat Of
  953. 0: Result := CurrencyString + Result;
  954. 1: Result := Result + CurrencyString;
  955. 2: Result := CurrencyString + ' ' + Result;
  956. 3: Result := Result + ' ' + CurrencyString;
  957. End
  958. End
  959. Else
  960. Begin
  961. Case NegCurrFormat Of
  962. 0: Result := '(' + CurrencyString + Result + ')';
  963. 1: Result := '-' + CurrencyString + Result;
  964. 2: Result := CurrencyString + '-' + Result;
  965. 3: Result := CurrencyString + Result + '-';
  966. 4: Result := '(' + Result + CurrencyString + ')';
  967. 5: Result := '-' + Result + CurrencyString;
  968. 6: Result := Result + '-' + CurrencyString;
  969. 7: Result := Result + CurrencyString + '-';
  970. 8: Result := '-' + Result + ' ' + CurrencyString;
  971. 9: Result := '-' + CurrencyString + ' ' + Result;
  972. 10: Result := CurrencyString + ' ' + Result + '-';
  973. End;
  974. End;
  975. End;
  976. End;
  977. End;
  978. Function FloatToDateTime (Const Value : Extended) : TDateTime;
  979. begin
  980. If (Value<MinDateTime) or (Value>MaxDateTime) then
  981. Raise EConvertError.CreateFmt (SInvalidDateTime,[Value]);
  982. Result:=Value;
  983. end;
  984. function TryFloatToCurr(const Value: Extended; var AResult: Currency): Boolean;
  985. begin
  986. {$ifndef VER1_0}
  987. Result:=(Value>=MinCurrency) and (Value<=MaxCurrency);
  988. if Result then
  989. AResult := Value;
  990. {$else VER1_0}
  991. Result:=false;
  992. {$endif VER1_0}
  993. end;
  994. function FloatToCurr(const Value: Extended): Currency;
  995. begin
  996. if not TryFloatToCurr(Value, Result) then
  997. Raise EConvertError.CreateFmt(SInvalidCurrency, [FloatToStr(Value)]);
  998. end;
  999. Function CurrToStr(Value: Currency): string;
  1000. begin
  1001. Result:=FloatToStrF(Value,ffNumber,15,2);
  1002. end;
  1003. function StrToCurr(const S: string): Currency;
  1004. begin
  1005. if not TextToFloat(PChar(S), Result, fvCurrency) then
  1006. Raise EConvertError.createfmt(SInValidFLoat,[S]);
  1007. end;
  1008. function StrToCurrDef(const S: string; Default : Currency): Currency;
  1009. begin
  1010. if not TextToFloat(PChar(S), Result, fvCurrency) then
  1011. Result:=Default;
  1012. end;
  1013. function StrToBool(const S: string): Boolean;
  1014. Var
  1015. Temp : String;
  1016. D : Double;
  1017. {$IFDEF VIRTUALPASCAL}
  1018. Code: longint;
  1019. {$ELSE}
  1020. Code: word;
  1021. {$ENDIF}
  1022. begin
  1023. Temp:=upcase(S);
  1024. Val(temp,D,code);
  1025. If Code=0 then
  1026. Result:=(D<>0.0)
  1027. else If Temp='TRUE' then
  1028. result:=true
  1029. else if Temp='FALSE' then
  1030. result:=false
  1031. else
  1032. Raise EConvertError.CreateFmt(SInvalidBoolean,[S]);
  1033. end;
  1034. function BoolToStr(B: Boolean): string;
  1035. begin
  1036. If B then
  1037. Result:='TRUE'
  1038. else
  1039. Result:='FALSE';
  1040. end;
  1041. Function FloatToTextFmt(Buffer: PChar; Value: Extended; format: PChar): Integer;
  1042. Var
  1043. Digits: String[40]; { String Of Digits }
  1044. Exponent: String[8]; { Exponent strin }
  1045. FmtStart, FmtStop: PChar; { Start And End Of relevant part }
  1046. { Of format String }
  1047. ExpFmt, ExpSize: Integer; { Type And Length Of }
  1048. { exponential format chosen }
  1049. Placehold: Array[1..4] Of Integer; { Number Of placeholders In All }
  1050. { four Sections }
  1051. thousand: Boolean; { thousand separators? }
  1052. UnexpectedDigits: Integer; { Number Of unexpected Digits that }
  1053. { have To be inserted before the }
  1054. { First placeholder. }
  1055. DigitExponent: Integer; { Exponent Of First digit In }
  1056. { Digits Array. }
  1057. { Find end of format section starting at P. False, if empty }
  1058. Function GetSectionEnd(Var P: PChar): Boolean;
  1059. Var
  1060. C: Char;
  1061. SQ, DQ: Boolean;
  1062. Begin
  1063. Result := False;
  1064. SQ := False;
  1065. DQ := False;
  1066. C := P[0];
  1067. While (C<>#0) And ((C<>';') Or SQ Or DQ) Do
  1068. Begin
  1069. Result := True;
  1070. Case C Of
  1071. #34: If Not SQ Then DQ := Not DQ;
  1072. #39: If Not DQ Then SQ := Not SQ;
  1073. End;
  1074. Inc(P);
  1075. C := P[0];
  1076. End;
  1077. End;
  1078. { Find start and end of format section to apply. If section doesn't exist,
  1079. use section 1. If section 2 is used, the sign of value is ignored. }
  1080. Procedure GetSectionRange(section: Integer);
  1081. Var
  1082. Sec: Array[1..3] Of PChar;
  1083. SecOk: Array[1..3] Of Boolean;
  1084. Begin
  1085. Sec[1] := format;
  1086. SecOk[1] := GetSectionEnd(Sec[1]);
  1087. If section > 1 Then
  1088. Begin
  1089. Sec[2] := Sec[1];
  1090. If Sec[2][0] <> #0 Then
  1091. Inc(Sec[2]);
  1092. SecOk[2] := GetSectionEnd(Sec[2]);
  1093. If section > 2 Then
  1094. Begin
  1095. Sec[3] := Sec[2];
  1096. If Sec[3][0] <> #0 Then
  1097. Inc(Sec[3]);
  1098. SecOk[3] := GetSectionEnd(Sec[3]);
  1099. End;
  1100. End;
  1101. If Not SecOk[1] Then
  1102. FmtStart := Nil
  1103. Else
  1104. Begin
  1105. If Not SecOk[section] Then
  1106. section := 1
  1107. Else If section = 2 Then
  1108. Value := -Value; { Remove sign }
  1109. If section = 1 Then FmtStart := format Else
  1110. Begin
  1111. FmtStart := Sec[section - 1];
  1112. Inc(FmtStart);
  1113. End;
  1114. FmtStop := Sec[section];
  1115. End;
  1116. End;
  1117. { Find format section ranging from FmtStart to FmtStop. }
  1118. Procedure GetFormatOptions;
  1119. Var
  1120. Fmt: PChar;
  1121. SQ, DQ: Boolean;
  1122. area: Integer;
  1123. Begin
  1124. SQ := False;
  1125. DQ := False;
  1126. Fmt := FmtStart;
  1127. ExpFmt := 0;
  1128. area := 1;
  1129. thousand := False;
  1130. Placehold[1] := 0;
  1131. Placehold[2] := 0;
  1132. Placehold[3] := 0;
  1133. Placehold[4] := 0;
  1134. While Fmt < FmtStop Do
  1135. Begin
  1136. Case Fmt[0] Of
  1137. #34:
  1138. Begin
  1139. If Not SQ Then
  1140. DQ := Not DQ;
  1141. Inc(Fmt);
  1142. End;
  1143. #39:
  1144. Begin
  1145. If Not DQ Then
  1146. SQ := Not SQ;
  1147. Inc(Fmt);
  1148. End;
  1149. Else
  1150. { This was 'if not SQ or DQ'. Looked wrong... }
  1151. If Not SQ Or DQ Then
  1152. Begin
  1153. Case Fmt[0] Of
  1154. '0':
  1155. Begin
  1156. Case area Of
  1157. 1:
  1158. area := 2;
  1159. 4:
  1160. Begin
  1161. area := 3;
  1162. Inc(Placehold[3], Placehold[4]);
  1163. Placehold[4] := 0;
  1164. End;
  1165. End;
  1166. Inc(Placehold[area]);
  1167. Inc(Fmt);
  1168. End;
  1169. '#':
  1170. Begin
  1171. If area=3 Then
  1172. area:=4;
  1173. Inc(Placehold[area]);
  1174. Inc(Fmt);
  1175. End;
  1176. '.':
  1177. Begin
  1178. If area<3 Then
  1179. area:=3;
  1180. Inc(Fmt);
  1181. End;
  1182. ',':
  1183. Begin
  1184. thousand := True;
  1185. Inc(Fmt);
  1186. End;
  1187. 'e', 'E':
  1188. If ExpFmt = 0 Then
  1189. Begin
  1190. If (Fmt[0]='E') Then
  1191. ExpFmt:=1
  1192. Else
  1193. ExpFmt := 3;
  1194. Inc(Fmt);
  1195. If (Fmt<FmtStop) Then
  1196. Begin
  1197. Case Fmt[0] Of
  1198. '+':
  1199. Begin
  1200. End;
  1201. '-':
  1202. Inc(ExpFmt);
  1203. Else
  1204. ExpFmt := 0;
  1205. End;
  1206. If ExpFmt <> 0 Then
  1207. Begin
  1208. Inc(Fmt);
  1209. ExpSize := 0;
  1210. While (Fmt<FmtStop) And
  1211. (ExpSize<4) And
  1212. (Fmt[0] In ['0'..'9']) Do
  1213. Begin
  1214. Inc(ExpSize);
  1215. Inc(Fmt);
  1216. End;
  1217. End;
  1218. End;
  1219. End
  1220. Else
  1221. Inc(Fmt);
  1222. Else { Case }
  1223. Inc(Fmt);
  1224. End; { Case }
  1225. End; { Begin }
  1226. End; { Case }
  1227. End; { While .. Begin }
  1228. End;
  1229. Procedure FloatToStr;
  1230. Var
  1231. I, J, Exp, Width, Decimals, DecimalPoint, len: Integer;
  1232. Begin
  1233. If ExpFmt = 0 Then
  1234. Begin
  1235. { Fixpoint }
  1236. Decimals:=Placehold[3]+Placehold[4];
  1237. Width:=Placehold[1]+Placehold[2]+Decimals;
  1238. If (Decimals=0) Then
  1239. Str(Value:Width:0,Digits)
  1240. Else
  1241. Str(Value:Width+1:Decimals,Digits);
  1242. len:=Length(Digits);
  1243. { Find the decimal point }
  1244. If (Decimals=0) Then
  1245. DecimalPoint:=len+1
  1246. Else
  1247. DecimalPoint:=len-Decimals;
  1248. { If value is very small, and no decimal places
  1249. are desired, remove the leading 0. }
  1250. If (Abs(Value) < 1) And (Placehold[2] = 0) Then
  1251. Begin
  1252. If (Placehold[1]=0) Then
  1253. Delete(Digits,DecimalPoint-1,1)
  1254. Else
  1255. Digits[DecimalPoint-1]:=' ';
  1256. End;
  1257. { Convert optional zeroes to spaces. }
  1258. I:=len;
  1259. J:=DecimalPoint+Placehold[3];
  1260. While (I>J) And (Digits[I]='0') Do
  1261. Begin
  1262. Digits[I] := ' ';
  1263. Dec(I);
  1264. End;
  1265. { If integer value and no obligatory decimal
  1266. places, remove decimal point. }
  1267. If (DecimalPoint < len) And (Digits[DecimalPoint + 1] = ' ') Then
  1268. Digits[DecimalPoint] := ' ';
  1269. { Convert spaces left from obligatory decimal point to zeroes. }
  1270. I:=DecimalPoint-Placehold[2];
  1271. While (I<DecimalPoint) And (Digits[I]=' ') Do
  1272. Begin
  1273. Digits[I] := '0';
  1274. Inc(I);
  1275. End;
  1276. Exp := 0;
  1277. End
  1278. Else
  1279. Begin
  1280. { Scientific: exactly <Width> Digits With <Precision> Decimals
  1281. And adjusted Exponent. }
  1282. If Placehold[1]+Placehold[2]=0 Then
  1283. Placehold[1]:=1;
  1284. Decimals := Placehold[3] + Placehold[4];
  1285. Width:=Placehold[1]+Placehold[2]+Decimals;
  1286. Str(Value:Width+8,Digits);
  1287. { Find and cut out exponent. Always the
  1288. last 6 characters in the string.
  1289. -> 0000E+0000 }
  1290. I:=Length(Digits)-5;
  1291. Val(Copy(Digits,I+1,5),Exp,J);
  1292. Exp:=Exp+1-(Placehold[1]+Placehold[2]);
  1293. Delete(Digits, I, 6);
  1294. { Str() always returns at least one digit after the decimal point.
  1295. If we don't want it, we have to remove it. }
  1296. If (Decimals=0) And (Placehold[1]+Placehold[2]<= 1) Then
  1297. Begin
  1298. If (Digits[4]>='5') Then
  1299. Begin
  1300. Inc(Digits[2]);
  1301. If (Digits[2]>'9') Then
  1302. Begin
  1303. Digits[2] := '1';
  1304. Inc(Exp);
  1305. End;
  1306. End;
  1307. Delete(Digits, 3, 2);
  1308. DecimalPoint := Length(Digits) + 1;
  1309. End
  1310. Else
  1311. Begin
  1312. { Move decimal point at the desired position }
  1313. Delete(Digits, 3, 1);
  1314. DecimalPoint:=2+Placehold[1]+Placehold[2];
  1315. If (Decimals<>0) Then
  1316. Insert('.',Digits,DecimalPoint);
  1317. End;
  1318. { Convert optional zeroes to spaces. }
  1319. I := Length(Digits);
  1320. J := DecimalPoint + Placehold[3];
  1321. While (I > J) And (Digits[I] = '0') Do
  1322. Begin
  1323. Digits[I] := ' ';
  1324. Dec(I);
  1325. End;
  1326. { If integer number and no obligatory decimal paces, remove decimal point }
  1327. If (DecimalPoint<Length(Digits)) And
  1328. (Digits[DecimalPoint+1]=' ') Then
  1329. Digits[DecimalPoint]:=' ';
  1330. If (Digits[1]=' ') Then
  1331. Begin
  1332. Delete(Digits, 1, 1);
  1333. Dec(DecimalPoint);
  1334. End;
  1335. { Calculate exponent string }
  1336. Str(Abs(Exp), Exponent);
  1337. While Length(Exponent)<ExpSize Do
  1338. Insert('0',Exponent,1);
  1339. If Exp >= 0 Then
  1340. Begin
  1341. If (ExpFmt In [1,3]) Then
  1342. Insert('+', Exponent, 1);
  1343. End
  1344. Else
  1345. Insert('-',Exponent,1);
  1346. If (ExpFmt<3) Then
  1347. Insert('E',Exponent,1)
  1348. Else
  1349. Insert('e',Exponent,1);
  1350. End;
  1351. DigitExponent:=DecimalPoint-2;
  1352. If (Digits[1]='-') Then
  1353. Dec(DigitExponent);
  1354. UnexpectedDigits:=DecimalPoint-1-(Placehold[1]+Placehold[2]);
  1355. End;
  1356. Function PutResult: LongInt;
  1357. Var
  1358. SQ, DQ: Boolean;
  1359. Fmt, Buf: PChar;
  1360. Dig, N: Integer;
  1361. Begin
  1362. SQ := False;
  1363. DQ := False;
  1364. Fmt := FmtStart;
  1365. Buf := Buffer;
  1366. Dig := 1;
  1367. While (Fmt<FmtStop) Do
  1368. Begin
  1369. //Write(Fmt[0]);
  1370. Case Fmt[0] Of
  1371. #34:
  1372. Begin
  1373. If Not SQ Then
  1374. DQ := Not DQ;
  1375. Inc(Fmt);
  1376. End;
  1377. #39:
  1378. Begin
  1379. If Not DQ Then
  1380. SQ := Not SQ;
  1381. Inc(Fmt);
  1382. End;
  1383. Else
  1384. If Not (SQ Or DQ) Then
  1385. Begin
  1386. Case Fmt[0] Of
  1387. '0', '#', '.':
  1388. Begin
  1389. If (Dig=1) And (UnexpectedDigits>0) Then
  1390. Begin
  1391. { Everything unexpected is written before the first digit }
  1392. For N := 1 To UnexpectedDigits Do
  1393. Begin
  1394. Buf[0] := Digits[N];
  1395. Inc(Buf);
  1396. If thousand And (Digits[N]<>'-') Then
  1397. Begin
  1398. If (DigitExponent Mod 3 = 0) And (DigitExponent>0) Then
  1399. Begin
  1400. Buf[0] := ThousandSeparator;
  1401. Inc(Buf);
  1402. End;
  1403. Dec(DigitExponent);
  1404. End;
  1405. End;
  1406. Inc(Dig, UnexpectedDigits);
  1407. End;
  1408. If (Digits[Dig]<>' ') Then
  1409. Begin
  1410. If (Digits[Dig]='.') Then
  1411. Buf[0] := DecimalSeparator
  1412. Else
  1413. Buf[0] := Digits[Dig];
  1414. Inc(Buf);
  1415. If thousand And (DigitExponent Mod 3 = 0) And (DigitExponent > 0) Then
  1416. Begin
  1417. Buf[0] := ThousandSeparator;
  1418. Inc(Buf);
  1419. End;
  1420. End;
  1421. Inc(Dig);
  1422. Dec(DigitExponent);
  1423. Inc(Fmt);
  1424. End;
  1425. 'e', 'E':
  1426. Begin
  1427. If ExpFmt <> 0 Then
  1428. Begin
  1429. Inc(Fmt);
  1430. If Fmt < FmtStop Then
  1431. Begin
  1432. If Fmt[0] In ['+', '-'] Then
  1433. Begin
  1434. Inc(Fmt, ExpSize);
  1435. For N:=1 To Length(Exponent) Do
  1436. Buf[N-1] := Exponent[N];
  1437. Inc(Buf,Length(Exponent));
  1438. ExpFmt:=0;
  1439. End;
  1440. Inc(Fmt);
  1441. End;
  1442. End
  1443. Else
  1444. Begin
  1445. { No legal exponential format.
  1446. Simply write the 'E' to the result. }
  1447. Buf[0] := Fmt[0];
  1448. Inc(Buf);
  1449. Inc(Fmt);
  1450. End;
  1451. End;
  1452. Else { Case }
  1453. { Usual character }
  1454. If (Fmt[0]<>',') Then
  1455. Begin
  1456. Buf[0] := Fmt[0];
  1457. Inc(Buf);
  1458. End;
  1459. Inc(Fmt);
  1460. End; { Case }
  1461. End
  1462. Else { IF }
  1463. Begin
  1464. { Character inside single or double quotes }
  1465. Buf[0] := Fmt[0];
  1466. Inc(Buf);
  1467. Inc(Fmt);
  1468. End;
  1469. End; { Case }
  1470. End; { While .. Begin }
  1471. Result:=PtrInt(Buf)-PtrInt(Buffer);
  1472. End;
  1473. Begin
  1474. If (Value>0) Then
  1475. GetSectionRange(1)
  1476. Else If (Value<0) Then
  1477. GetSectionRange(2)
  1478. Else
  1479. GetSectionRange(3);
  1480. If FmtStart = Nil Then
  1481. Begin
  1482. Result := FloatToText(Buffer, Value, ffGeneral, 15, 4);
  1483. End
  1484. Else
  1485. Begin
  1486. GetFormatOptions;
  1487. If (ExpFmt = 0) And (Abs(Value) >= 1E18) Then
  1488. Result := FloatToText(Buffer, Value, ffGeneral, 15, 4)
  1489. Else
  1490. Begin
  1491. FloatToStr;
  1492. Result := PutResult;
  1493. End;
  1494. End;
  1495. End;
  1496. Procedure FloatToDecimal(Var Result: TFloatRec; Value: Extended; Precision, Decimals : integer);
  1497. Var
  1498. Buffer: String[24];
  1499. Error, N: Integer;
  1500. Begin
  1501. Str(Value:23, Buffer);
  1502. Result.Negative := (Buffer[1] = '-');
  1503. Val(Copy(Buffer, 19, 5), Result.Exponent, Error);
  1504. Inc(Result. Exponent);
  1505. Result.Digits[0] := Buffer[2];
  1506. Move(Buffer[4], Result.Digits[1], 14);
  1507. If Decimals + Result.Exponent < Precision Then
  1508. N := Decimals + Result.Exponent
  1509. Else
  1510. N := Precision;
  1511. If N > 15 Then
  1512. N := 15;
  1513. If N = 0 Then
  1514. Begin
  1515. If Result.Digits[0] >= '5' Then
  1516. Begin
  1517. Result.Digits[0] := '1';
  1518. Result.Digits[1] := #0;
  1519. Inc(Result.Exponent);
  1520. End
  1521. Else
  1522. Result.Digits[0] := #0;
  1523. End
  1524. Else If N > 0 Then
  1525. Begin
  1526. If Result.Digits[N] >= '5' Then
  1527. Begin
  1528. Repeat
  1529. Result.Digits[N] := #0;
  1530. Dec(N);
  1531. Inc(Result.Digits[N]);
  1532. Until (N = 0) Or (Result.Digits[N] < ':');
  1533. If Result.Digits[0] = ':' Then
  1534. Begin
  1535. Result.Digits[0] := '1';
  1536. Inc(Result.Exponent);
  1537. End;
  1538. End
  1539. Else
  1540. Begin
  1541. Result.Digits[N] := '0';
  1542. While (Result.Digits[N] = '0') And (N > -1) Do
  1543. Begin
  1544. Result.Digits[N] := #0;
  1545. Dec(N);
  1546. End;
  1547. End;
  1548. End
  1549. Else
  1550. Result.Digits[0] := #0;
  1551. If Result.Digits[0] = #0 Then
  1552. Begin
  1553. Result.Exponent := 0;
  1554. Result.Negative := False;
  1555. End;
  1556. End;
  1557. Function FormatFloat(Const format: String; Value: Extended): String;
  1558. Var
  1559. buf : Array[0..1024] of char;
  1560. Begin
  1561. Buf[FloatToTextFmt(@Buf[0],Value,Pchar(Format))]:=#0;
  1562. Result:=StrPas(@Buf);
  1563. End;
  1564. function FormatCurr(const Format: string; Value: Currency): string;
  1565. begin
  1566. Result := FormatFloat(Format, Value);
  1567. end;
  1568. {==============================================================================}
  1569. { extra functions }
  1570. {==============================================================================}
  1571. { LeftStr returns Count left-most characters from S }
  1572. function LeftStr(const S: string; Count: integer): string;
  1573. begin
  1574. result := Copy(S, 1, Count);
  1575. end ;
  1576. { RightStr returns Count right-most characters from S }
  1577. function RightStr(const S: string; Count: integer): string;
  1578. begin
  1579. If Count>Length(S) then
  1580. Count:=Length(S);
  1581. result := Copy(S, 1 + Length(S) - Count, Count);
  1582. end;
  1583. { BCDToInt converts the BCD value Value to an integer }
  1584. function BCDToInt(Value: integer): integer;
  1585. var i, j: integer;
  1586. begin
  1587. result := 0;
  1588. j := 1;
  1589. for i := 0 to SizeOf(Value) shr 1 - 1 do begin
  1590. result := result + j * (Value and 15);
  1591. j := j * 10;
  1592. Value := Value shr 4;
  1593. end ;
  1594. end ;
  1595. Function LastDelimiter(const Delimiters, S: string): Integer;
  1596. begin
  1597. Result:=Length(S);
  1598. While (Result>0) and (Pos(S[Result],Delimiters)=0) do
  1599. Dec(Result);
  1600. end;
  1601. Function StringReplace(const S, OldPattern, NewPattern: string; Flags: TReplaceFlags): string;
  1602. var
  1603. Srch,OldP,RemS: string; // Srch and Oldp can contain uppercase versions of S,OldPattern
  1604. P : Integer;
  1605. begin
  1606. Srch:=S;
  1607. OldP:=OldPattern;
  1608. if rfIgnoreCase in Flags then
  1609. begin
  1610. Srch:=UpperCase(Srch);
  1611. OldP:=UpperCase(OldP);
  1612. end;
  1613. RemS:=S;
  1614. Result:='';
  1615. while (Length(Srch)<>0) do
  1616. begin
  1617. P:=Pos(OldP, Srch);
  1618. if P=0 then
  1619. begin
  1620. Result:=Result+RemS;
  1621. Srch:='';
  1622. end
  1623. else
  1624. begin
  1625. Result:=Result+Copy(RemS,1,P-1)+NewPattern;
  1626. P:=P+Length(OldP);
  1627. RemS:=Copy(RemS,P,Length(RemS)-P+1);
  1628. if not (rfReplaceAll in Flags) then
  1629. begin
  1630. Result:=Result+RemS;
  1631. Srch:='';
  1632. end
  1633. else
  1634. Srch:=Copy(Srch,P,Length(Srch)-P+1);
  1635. end;
  1636. end;
  1637. end;
  1638. Function IsDelimiter(const Delimiters, S: string; Index: Integer): Boolean;
  1639. begin
  1640. Result:=False;
  1641. If (Index>0) and (Index<=Length(S)) then
  1642. Result:=Pos(S[Index],Delimiters)<>0; // Note we don't do MBCS yet
  1643. end;
  1644. Function ByteToCharLen(const S: string; MaxLen: Integer): Integer;
  1645. begin
  1646. Result:=Length(S);
  1647. If Result>MaxLen then
  1648. Result:=MaxLen;
  1649. end;
  1650. Function ByteToCharIndex(const S: string; Index: Integer): Integer;
  1651. begin
  1652. Result:=Index;
  1653. end;
  1654. Function CharToByteLen(const S: string; MaxLen: Integer): Integer;
  1655. begin
  1656. Result:=Length(S);
  1657. If Result>MaxLen then
  1658. Result:=MaxLen;
  1659. end;
  1660. Function CharToByteIndex(const S: string; Index: Integer): Integer;
  1661. begin
  1662. Result:=Index;
  1663. end;
  1664. Function ByteType(const S: string; Index: Integer): TMbcsByteType;
  1665. begin
  1666. Result:=mbSingleByte;
  1667. end;
  1668. Function StrByteType(Str: PChar; Index: Cardinal): TMbcsByteType;
  1669. begin
  1670. Result:=mbSingleByte;
  1671. end;
  1672. Function StrCharLength(const Str: PChar): Integer;
  1673. begin
  1674. {$ifdef HASWIDESTRING}
  1675. result:=widestringmanager.CharLengthPCharProc(Str);
  1676. {$endif HASWIDESTRING}
  1677. end;
  1678. Function FindCmdLineSwitch(const Switch: string; const Chars: TSysCharSet;IgnoreCase: Boolean): Boolean;
  1679. Var
  1680. I,L : Integer;
  1681. S,T : String;
  1682. begin
  1683. Result:=False;
  1684. S:=Switch;
  1685. If IgnoreCase then
  1686. S:=UpperCase(S);
  1687. I:=ParamCount;
  1688. While (Not Result) and (I>0) do
  1689. begin
  1690. L:=Length(Paramstr(I));
  1691. If (L>0) and (ParamStr(I)[1] in Chars) then
  1692. begin
  1693. T:=Copy(ParamStr(I),2,L-1);
  1694. If IgnoreCase then
  1695. T:=UpperCase(T);
  1696. Result:=S=T;
  1697. end;
  1698. Dec(i);
  1699. end;
  1700. end;
  1701. Function FindCmdLineSwitch(const Switch: string; IgnoreCase: Boolean): Boolean;
  1702. begin
  1703. Result:=FindCmdLineSwitch(Switch,SwitchChars,IgnoreCase);
  1704. end;
  1705. Function FindCmdLineSwitch(const Switch: string): Boolean;
  1706. begin
  1707. Result:=FindCmdLineSwitch(Switch,SwitchChars,False);
  1708. end;
  1709. function WrapText(const Line, BreakStr: string; const BreakChars: TSysCharSet; MaxCol: Integer): string;
  1710. const
  1711. Quotes = ['''', '"'];
  1712. Var
  1713. L : String;
  1714. C,LQ,BC : Char;
  1715. P,BLen,Len : Integer;
  1716. HB,IBC : Boolean;
  1717. begin
  1718. Result:='';
  1719. L:=Line;
  1720. Blen:=Length(BreakStr);
  1721. If (BLen>0) then
  1722. BC:=BreakStr[1]
  1723. else
  1724. BC:=#0;
  1725. Len:=Length(L);
  1726. While (Len>0) do
  1727. begin
  1728. P:=1;
  1729. LQ:=#0;
  1730. HB:=False;
  1731. IBC:=False;
  1732. While ((P<=Len) and ((P<=MaxCol) or not IBC)) and ((LQ<>#0) or Not HB) do
  1733. begin
  1734. C:=L[P];
  1735. If (C=LQ) then
  1736. LQ:=#0
  1737. else If (C in Quotes) then
  1738. LQ:=C;
  1739. If (LQ<>#0) then
  1740. Inc(P)
  1741. else
  1742. begin
  1743. HB:=((C=BC) and (BreakStr=Copy(L,P,BLen)));
  1744. If HB then
  1745. Inc(P,Blen)
  1746. else
  1747. begin
  1748. If (P>MaxCol) then
  1749. IBC:=C in BreakChars;
  1750. Inc(P);
  1751. end;
  1752. end;
  1753. // Writeln('"',C,'" : IBC : ',IBC,' HB : ',HB,' LQ : ',LQ,' P>MaxCol : ',P>MaxCol);
  1754. end;
  1755. Result:=Result+Copy(L,1,P-1);
  1756. If Not HB then
  1757. Result:=Result+BreakStr;
  1758. Delete(L,1,P-1);
  1759. Len:=Length(L);
  1760. end;
  1761. end;
  1762. function WrapText(const Line: string; MaxCol: Integer): string;
  1763. begin
  1764. Result:=WrapText(Line,sLineBreak, [' ', '-', #9], MaxCol);
  1765. end;
  1766. {
  1767. Case Translation Tables
  1768. Can be used in internationalization support.
  1769. Although these tables can be obtained through system calls
  1770. it is better to not use those, since most implementation are not 100%
  1771. WARNING:
  1772. before modifying a translation table make sure that the current codepage
  1773. of the OS corresponds to the one you make changes to
  1774. }
  1775. const
  1776. { upper case translation table for character set 850 }
  1777. CP850UCT: array[128..255] of char =
  1778. ('€', 'š', '�', '¶', 'Ž', '¶', '�', '€', 'Ò', 'Ó', 'Ô', 'Ø', '×', 'Þ', 'Ž', '�',
  1779. '�', '’', '’', 'â', '™', 'ã', 'ê', 'ë', 'Y', '™', 'š', '�', 'œ', '�', 'ž', 'Ÿ',
  1780. 'µ', 'Ö', 'à', 'é', '¥', '¥', '¦', '§', '¨', '©', 'ª', '«', '¬', '­', '®', '¯',
  1781. '°', '±', '²', '³', '´', 'µ', '¶', '·', '¸', '¹', 'º', '»', '¼', '½', '¾', '¿',
  1782. 'À', 'Á', 'Â', 'Ã', 'Ä', 'Å', 'Ç', 'Ç', 'È', 'É', 'Ê', 'Ë', 'Ì', 'Í', 'Î', 'Ï',
  1783. 'Ð', 'Ñ', 'Ò', 'Ó', 'Ô', 'Õ', 'Ö', '×', 'Ø', 'Ù', 'Ú', 'Û', 'Ü', 'Ý', 'Þ', 'ß',
  1784. 'à', 'á', 'â', 'ã', 'å', 'å', 'æ', 'í', 'è', 'é', 'ê', 'ë', 'í', 'í', 'î', 'ï',
  1785. 'ð', 'ñ', 'ò', 'ó', 'ô', 'õ', 'ö', '÷', 'ø', 'ù', 'ú', 'û', 'ü', 'ý', 'þ', 'ÿ');
  1786. { lower case translation table for character set 850 }
  1787. CP850LCT: array[128..255] of char =
  1788. ('‡', '�', '‚', 'ƒ', '„', '…', '†', '‡', 'ˆ', '‰', 'Š', '‹', 'Œ', '�', '„', '†',
  1789. '‚', '‘', '‘', '“', '”', '•', '–', '—', '˜', '”', '�', '›', 'œ', '›', 'ž', 'Ÿ',
  1790. ' ', '¡', '¢', '£', '¤', '¤', '¦', '§', '¨', '©', 'ª', '«', '¬', '­', '®', '¯',
  1791. '°', '±', '²', '³', '´', ' ', 'ƒ', '…', '¸', '¹', 'º', '»', '¼', '½', '¾', '¿',
  1792. 'À', 'Á', 'Â', 'Ã', 'Ä', 'Å', 'Æ', 'Æ', 'È', 'É', 'Ê', 'Ë', 'Ì', 'Í', 'Î', 'Ï',
  1793. 'Ð', 'Ñ', 'ˆ', '‰', 'Š', 'Õ', '¡', 'Œ', '‹', 'Ù', 'Ú', 'Û', 'Ü', 'Ý', '�', 'ß',
  1794. '¢', 'á', '“', '•', 'ä', 'ä', 'æ', 'í', 'è', '£', '–', '—', 'ì', 'ì', 'î', 'ï',
  1795. 'ð', 'ñ', 'ò', 'ó', 'ô', 'õ', 'ö', '÷', 'ø', 'ù', 'ú', 'û', 'ü', 'ý', 'þ', 'ÿ');
  1796. { upper case translation table for character set ISO 8859/1 Latin 1 }
  1797. CPISO88591UCT: array[192..255] of char =
  1798. ( #192, #193, #194, #195, #196, #197, #198, #199,
  1799. #200, #201, #202, #203, #204, #205, #206, #207,
  1800. #208, #209, #210, #211, #212, #213, #214, #215,
  1801. #216, #217, #218, #219, #220, #221, #222, #223,
  1802. #192, #193, #194, #195, #196, #197, #198, #199,
  1803. #200, #201, #202, #203, #204, #205, #206, #207,
  1804. #208, #209, #210, #211, #212, #213, #214, #247,
  1805. #216, #217, #218, #219, #220, #221, #222, #89 );
  1806. { lower case translation table for character set ISO 8859/1 Latin 1 }
  1807. CPISO88591LCT: array[192..255] of char =
  1808. ( #224, #225, #226, #227, #228, #229, #230, #231,
  1809. #232, #233, #234, #235, #236, #237, #238, #239,
  1810. #240, #241, #242, #243, #244, #245, #246, #215,
  1811. #248, #249, #250, #251, #252, #253, #254, #223,
  1812. #224, #225, #226, #227, #228, #229, #230, #231,
  1813. #232, #233, #234, #235, #236, #237, #238, #239,
  1814. #240, #241, #242, #243, #244, #245, #246, #247,
  1815. #248, #249, #250, #251, #252, #253, #254, #255 );
  1816. {
  1817. $Log$
  1818. Revision 1.36 2005-04-26 16:40:51 michael
  1819. + Added FormatCurr by Uberto Barbini
  1820. Revision 1.35 2005/03/25 22:53:39 jonas
  1821. * fixed several warnings and notes about unused variables (mainly) or
  1822. uninitialised use of variables/function results (a few)
  1823. Revision 1.34 2005/03/13 14:30:24 marco
  1824. * some 1.0.x fixes
  1825. Revision 1.33 2005/03/12 14:56:22 florian
  1826. + added Ansi* routines to widestring manager
  1827. * made them using OS calls on windows
  1828. Revision 1.32 2005/03/01 19:23:03 jonas
  1829. * fixed newstr() and disposestr()
  1830. Revision 1.31 2005/02/28 11:12:17 jonas
  1831. * fixed web bug 3708
  1832. Revision 1.30 2005/02/26 10:21:17 florian
  1833. + implemented WideFormat
  1834. + some Widestring stuff implemented
  1835. * some Widestring stuff fixed
  1836. Revision 1.29 2005/02/14 17:13:31 peter
  1837. * truncate log
  1838. Revision 1.28 2005/02/07 08:29:00 michael
  1839. + Patch from peter to fix 1.0 compile
  1840. Revision 1.27 2005/02/06 09:38:45 florian
  1841. + StrCharLength infrastructure
  1842. Revision 1.26 2005/01/17 18:38:48 peter
  1843. * extended overload disabled for powerpc
  1844. Revision 1.25 2005/01/16 17:53:27 michael
  1845. + Patch from Colin Western to implemenet TryStrToFLoat
  1846. }