jastrings.inc 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 1999-2000 by Michael Van Canneyt,
  4. member of the Free Pascal development team.
  5. This file implements AnsiStrings for FPC
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. { This will release some functions for special shortstring support }
  13. { define EXTRAANSISHORT}
  14. constructor AnsistringClass.Create(len: longint);
  15. begin
  16. { +1 for terminating #0 }
  17. setlength(fdata,len+1);
  18. end;
  19. constructor AnsistringClass.Create(const arr: array of ansichar; length: longint);
  20. begin
  21. { make explicit copy so that changing the array afterwards doesn't change
  22. the string }
  23. if length=0 then
  24. begin
  25. { terminating #0 }
  26. setlength(fdata,1);
  27. exit;
  28. end;
  29. setlength(fdata,length+1);
  30. JLSystem.ArrayCopy(JLObject(@arr),0,JLObject(fdata),0,length);
  31. // last char is already #0 because of setlength
  32. end;
  33. constructor AnsistringClass.Create(const arr: array of unicodechar);
  34. begin
  35. if high(arr)=-1 then
  36. begin
  37. { terminating #0 }
  38. setlength(fdata,1);
  39. exit;
  40. end;
  41. fdata:=TAnsiCharArray(JLString.Create(arr).getBytes);
  42. setlength(fdata,system.length(fdata)+1);
  43. // last char is already #0 because of setlength
  44. end;
  45. constructor AnsistringClass.Create(const u: unicodestring);
  46. begin
  47. if system.length(u)=0 then
  48. begin
  49. { terminating #0 }
  50. setlength(fdata,1);
  51. exit;
  52. end;
  53. fdata:=TAnsiCharArray(JLString(u).getBytes);
  54. setlength(fdata,system.length(fdata)+1);
  55. // last char is already #0 because of setlength
  56. end;
  57. constructor AnsistringClass.Create(const a: ansistring);
  58. begin
  59. Create(AnsistringClass(a).fdata,system.length(AnsistringClass(a).fdata)-1);
  60. end;
  61. constructor AnsistringClass.Create(const s: shortstring);
  62. begin
  63. Create(ShortstringClass(@s).fdata,system.length(ShortstringClass(@s).fdata));
  64. end;
  65. constructor AnsistringClass.Create(ch: ansichar);
  66. begin
  67. setlength(fdata,2);
  68. fdata[0]:=ch;
  69. // last char is already #0 because of setlength
  70. end;
  71. constructor AnsistringClass.Create(ch: unicodechar);
  72. begin
  73. fdata:=TAnsiCharArray(JLString.Create(ch).getBytes);
  74. setlength(fdata,system.length(fdata)+1);
  75. // last char is already #0 because of setlength
  76. end;
  77. class function AnsistringClass.CreateFromLiteralStringBytes(const u: unicodestring): ansistring;
  78. var
  79. res: AnsistringClass;
  80. i: longint;
  81. begin
  82. { used to construct constant ansistrings from Java string constants }
  83. res:=AnsistringClass.Create;
  84. { +1 for terminating #0 }
  85. setlength(res.fdata,system.length(u)+1);
  86. for i:=1 to system.length(u) do
  87. res.fdata[i-1]:=ansichar(ord(u[i]));
  88. result:=ansistring(res);
  89. end;
  90. function AnsistringClass.charAt(index: jint): ansichar;
  91. begin
  92. { index is already decreased by one, because same calling code is used for
  93. JLString.charAt() }
  94. result:=fdata[index];
  95. end;
  96. function AnsistringClass.toUnicodeString: unicodestring;
  97. begin
  98. result:=UnicodeString(JLString.Create(TJByteArray(fdata),0,system.length(fdata)-1));
  99. end;
  100. function AnsistringClass.toShortstring(maxlen: byte): shortstring;
  101. begin
  102. result:=pshortstring(ShortstringClass.Create(ansistring(self),maxlen))^;
  103. end;
  104. function AnsistringClass.toString: JLString;
  105. begin
  106. result:=JLString.Create(TJByteArray(fdata),0,system.length(fdata)-1);
  107. end;
  108. (*
  109. function AnsistringClass.concat(const a: ansistring): ansistring;
  110. var
  111. newdata: array of ansichar;
  112. addlen: sizeint;
  113. begin
  114. addlen:=length(a);
  115. thislen:=this.length;
  116. setlength(newdata,addlen+thislen);
  117. if thislen>0 then
  118. JLSystem.ArrayCopy(JLObject(fdata),0,JLObject(newdata),0,thislen);
  119. if addlen>0 then
  120. JLSystem.ArrayCopy(JLObject(AnsistringClass(a).fdata),0,JLObject(newdata),thislen,addlen);
  121. end;
  122. procedure AnsistringClass.concatmultiple(const arr: array of ansistring): ansistring;
  123. Var
  124. i : longint;
  125. size, newsize : sizeint;
  126. curlen, addlen : sizeint
  127. newdata: array of ansichar;
  128. begin
  129. { First calculate size of the result so we can allocate an array of
  130. the right size }
  131. NewSize:=0;
  132. for i:=low(arr) to high(arr) do
  133. inc(newsize,length(arr[i]));
  134. setlength(newdata,newsize);
  135. curlen
  136. for i:=low(arr) to high(arr) do
  137. begin
  138. if length(arr[i])>0 then
  139. sb.append(arr[i]);
  140. end;
  141. DestS:=sb.toString;
  142. end;
  143. *)
  144. function AnsiStringClass.length: jint;
  145. begin
  146. result:=system.length(fdata)-1;
  147. end;
  148. {****************************************************************************
  149. Internal functions, not in interface.
  150. ****************************************************************************}
  151. {$ifndef FPC_HAS_PCHAR_ANSISTR_INTERN_CHARMOVE}
  152. {$define FPC_HAS_PCHAR_ANSISTR_INTERN_CHARMOVE}
  153. procedure fpc_pchar_ansistr_intern_charmove(const src: pchar; const srcindex: sizeint; var dst: ansistring; const dstindex, len: sizeint); {$ifdef SYSTEMINLINE}inline;{$endif}
  154. begin
  155. JLSystem.arraycopy(JLObject(src),srcindex,JLObject(AnsistringClass(dst).fdata),dstindex,len);
  156. end;
  157. {$endif FPC_HAS_PCHAR_ANSISTR_INTERN_CHARMOVE}
  158. {$define FPC_HAS_NEWANSISTR}
  159. Function NewAnsiString(Len : SizeInt) : Pointer;
  160. {
  161. Allocate a new AnsiString on the heap.
  162. initialize it to zero length and reference count 1.
  163. }
  164. begin
  165. result:=AnsistringClass.Create(len);
  166. end;
  167. { not required }
  168. {$define FPC_HAS_DISPOSE_ANSISTR}
  169. {$define FPC_SYSTEM_HAS_ANSISTR_DECR_REF}
  170. {$define FPC_SYSTEM_HAS_ANSISTR_INCR_REF}
  171. {$define FPC_HAS_ANSISTR_ASSIGN}
  172. {$define FPC_HAS_ANSISTR_CONCAT}
  173. procedure fpc_AnsiStr_Concat (var DestS:ansistring;const S1,S2 : AnsiString); compilerproc;
  174. var
  175. newdata: array of ansichar;
  176. thislen, addlen: sizeint;
  177. begin
  178. thislen:=length(s1);
  179. addlen:=length(s2);
  180. { +1 for terminating #0 }
  181. setlength(newdata,thislen+addlen+1);
  182. if thislen>0 then
  183. JLSystem.ArrayCopy(JLObject(AnsistringClass(s1).fdata),0,JLObject(newdata),0,thislen);
  184. if addlen>0 then
  185. JLSystem.ArrayCopy(JLObject(AnsistringClass(s2).fdata),0,JLObject(newdata),thislen,addlen);
  186. dests:=Ansistring(AnsistringClass.Create);
  187. AnsistringClass(dests).fdata:=newdata;
  188. end;
  189. {$define FPC_HAS_ANSISTR_CONCAT_MULTI}
  190. procedure fpc_AnsiStr_Concat_multi (var DestS:Ansistring;const sarr:array of Ansistring); compilerproc;
  191. Var
  192. i : longint;
  193. size, newsize : sizeint;
  194. curlen, addlen, nextlen : sizeint;
  195. newdata: array of ansichar;
  196. res : AnsistringClass;
  197. begin
  198. { First calculate size of the result so we can allocate an array of
  199. the right size }
  200. NewSize:=0;
  201. for i:=low(sarr) to high(sarr) do
  202. inc(newsize,length(sarr[i]));
  203. { +1 for terminating #0 }
  204. setlength(newdata,newsize+1);
  205. curlen:=0;
  206. for i:=low(sarr) to high(sarr) do
  207. begin
  208. nextlen:=length(sarr[i]);
  209. if nextlen>0 then
  210. begin
  211. JLSystem.ArrayCopy(JLObject(AnsistringClass(sarr[i]).fdata),0,JLObject(newdata),curlen,nextlen);
  212. inc(curlen,nextlen);
  213. end;
  214. end;
  215. res:=AnsistringClass.Create;
  216. res.fdata:=newdata;
  217. dests:=Ansistring(res);
  218. end;
  219. {$define FPC_HAS_ANSISTR_TO_SHORTSTR}
  220. procedure fpc_AnsiStr_To_ShortStr (out res: shortstring; const S2 : Ansistring); compilerproc;
  221. {
  222. Converts a AnsiString to a ShortString;
  223. }
  224. Var
  225. Size : SizeInt;
  226. begin
  227. if S2='' then
  228. res:=''
  229. else
  230. begin
  231. Size:=Length(S2);
  232. If Size>high(res) then
  233. Size:=high(res);
  234. JLSystem.ArrayCopy(JLObject(AnsistringClass(S2).fdata),0,JLObject(ShortstringClass(@res).fdata),0,Size);
  235. setlength(res,Size);
  236. end;
  237. end;
  238. {$define FPC_HAS_SHORTSTR_TO_ANSISTR}
  239. Function fpc_ShortStr_To_AnsiStr (Const S2 : ShortString): ansistring; compilerproc;
  240. {
  241. Converts a ShortString to a AnsiString;
  242. }
  243. Var
  244. Size : SizeInt;
  245. begin
  246. Size:=Length(S2);
  247. Setlength(result,Size);
  248. if Size>0 then
  249. JLSystem.ArrayCopy(JLObject(ShortstringClass(@S2).fdata),0,JLObject(AnsistringClass(result).fdata),0,Size);
  250. end;
  251. {$define FPC_HAS_CHAR_TO_ANSISTR}
  252. Function fpc_Char_To_AnsiStr(const c : AnsiChar): AnsiString; compilerproc;
  253. {
  254. Converts a Char to a AnsiString;
  255. }
  256. begin
  257. result:=ansistring(AnsistringClass.Create(c));
  258. end;
  259. {$define FPC_HAS_PCHAR_TO_ANSISTR}
  260. Function fpc_PChar_To_AnsiStr(const p : pchar): ansistring; compilerproc;
  261. var
  262. i, len: longint;
  263. arr: TAnsiCharArray;
  264. begin
  265. arr:=TAnsiCharArray(p);
  266. i:=0;
  267. while arr[i]<>#0 do
  268. inc(i);
  269. if i<>0 then
  270. result:=ansistring(AnsiStringClass.create(arr,i))
  271. else
  272. result:=''
  273. end;
  274. {$define FPC_HAS_CHARARRAY_TO_ANSISTR}
  275. Function fpc_CharArray_To_AnsiStr(const arr: array of ansichar; zerobased: boolean = true): ansistring; compilerproc;
  276. var
  277. i,j : SizeInt;
  278. localarr: array of jbyte;
  279. foundnull: boolean;
  280. res: AnsistringClass;
  281. begin
  282. if (zerobased) then
  283. begin
  284. if (arr[0]=#0) Then
  285. begin
  286. fpc_CharArray_To_AnsiStr := '';
  287. exit;
  288. end;
  289. foundnull:=false;
  290. j:=0;
  291. for i:=low(arr) to high(arr) do
  292. if arr[i]=#0 then
  293. begin
  294. foundnull:=true;
  295. j:=i;
  296. break;
  297. end;
  298. if foundnull then
  299. begin
  300. res:=AnsistringClass.Create(arr,j);
  301. exit;
  302. end
  303. end
  304. else
  305. begin
  306. res:=AnsistringClass.Create(arr);
  307. exit;
  308. end;
  309. res:=AnsistringClass.Create;
  310. { +1 for terminating 0 }
  311. setlength(res.fdata,high(arr)+2);
  312. JLSystem.ArrayCopy(JLObject(@arr),0,JLObject(res.fdata),0,high(arr)+1);
  313. result:=Ansistring(res);
  314. end;
  315. {$define FPC_HAS_ANSISTR_TO_CHARARRAY}
  316. procedure fpc_ansistr_to_chararray(out res: array of ansichar; const src: ansistring); compilerproc;
  317. var
  318. len: longint;
  319. begin
  320. len:=length(src);
  321. if len>length(res) then
  322. len:=length(res);
  323. { make sure we don't try to access element 1 of the ansistring if it's nil }
  324. if len>0 then
  325. JLSystem.ArrayCopy(JLObject(AnsistringClass(src).fdata),0,JLObject(@res),0,len);
  326. if len<=high(res) then
  327. JUArrays.fill(TJByteArray(@res),len,high(res),0);
  328. end;
  329. function fpc_ansistr_setchar(const s: AnsiString; const index: longint; const ch: ansichar): AnsiString; compilerproc;
  330. var
  331. res: AnsistringClass;
  332. begin
  333. res:=AnsistringClass.Create(s);
  334. res.fdata[index-1]:=ch;
  335. result:=Ansistring(res);
  336. end;
  337. {$define FPC_HAS_ANSISTR_COMPARE}
  338. Function fpc_AnsiStr_Compare(const S1,S2 : AnsiString): SizeInt; compilerproc;
  339. {
  340. Compares 2 AnsiStrings;
  341. The result is
  342. <0 if S1<S2
  343. 0 if S1=S2
  344. >0 if S1>S2
  345. }
  346. Var
  347. MaxI,Temp, i : SizeInt;
  348. begin
  349. if JLObject(S1)=JLObject(S2) then
  350. begin
  351. result:=0;
  352. exit;
  353. end;
  354. Maxi:=Length(S1);
  355. temp:=Length(S2);
  356. If MaxI>Temp then
  357. MaxI:=Temp;
  358. if MaxI>0 then
  359. begin
  360. for i:=0 to MaxI-1 do
  361. begin
  362. result:=ord(AnsistringClass(S1).fdata[i])-ord(AnsistringClass(S2).fdata[i]);
  363. if result<>0 then
  364. exit;
  365. end;
  366. result:=Length(S1)-Length(S2);
  367. end
  368. else
  369. result:=Length(S1)-Length(S2);
  370. end;
  371. {$define FPC_HAS_ANSISTR_COMPARE_EQUAL}
  372. Function fpc_AnsiStr_Compare_equal(const S1,S2 : AnsiString): SizeInt; compilerproc;
  373. {
  374. Compares 2 AnsiStrings for equality/inequality only;
  375. The result is
  376. 0 if S1=S2
  377. <>0 if S1<>S2
  378. }
  379. Var
  380. MaxI,Temp : SizeInt;
  381. begin
  382. if JLObject(S1)=JLObject(S2) then
  383. begin
  384. result:=0;
  385. exit;
  386. end;
  387. result:=ord(not JUArrays.equals(TJByteArray(AnsistringClass(S1).fdata),TJByteArray(AnsistringClass(S2).fdata)));
  388. end;
  389. { not required, the JVM does the range checking for us }
  390. {$define FPC_HAS_ANSISTR_CHECKRANGE}
  391. {$define FPC_HAS_ANSISTR_SETLENGTH}
  392. function fpc_AnsiStr_SetLength (S : AnsiString; l : SizeInt): Ansistring; compilerproc;
  393. {
  394. Sets The length of string S to L.
  395. Makes sure S is unique, and contains enough room.
  396. }
  397. begin
  398. if not assigned(AnsistringClass(s)) then
  399. result:=ansistring(AnsistringClass.Create)
  400. else
  401. result:=s;
  402. { +1 for terminating #0 }
  403. setlength(AnsistringClass(result).fdata,l+1);
  404. { null-terminate in case the string became shorter }
  405. AnsistringClass(result).fdata[l]:=#0;
  406. end;
  407. {*****************************************************************************
  408. Public functions, In interface.
  409. *****************************************************************************}
  410. { lie, not needed }
  411. {$define FPC_SYSTEM_HAS_TRUELY_ANSISTR_UNIQUE}
  412. { can't implement reference counting since no control over what javacc-compiled
  413. code does with ansistrings -> always create a copy }
  414. {$define FPC_SYSTEM_HAS_ANSISTR_UNIQUE}
  415. procedure FPC_ANSISTR_UNIQUE(var s: AnsiString); inline;
  416. begin
  417. s:=ansistring(AnsistringClass.Create(s));
  418. end;
  419. (*
  420. Function fpc_ansistr_Unique(Var S : jlobject): jlobject; compilerproc;
  421. begin
  422. s:=AnsistringClass.Create(ansistring(s));
  423. result:=s;
  424. end;
  425. *)
  426. {$define FPC_HAS_ANSISTR_APPEND_CHAR}
  427. Procedure fpc_ansistr_append_char(Var S : AnsiString;c : ansichar); compilerproc;
  428. var
  429. curlen: sizeint;
  430. begin
  431. curlen:=length(s);
  432. SetLength(s,curlen+1);
  433. AnsistringClass(s).fdata[curlen]:=c;
  434. end;
  435. {$define FPC_HAS_ANSISTR_APPEND_SHORTSTR}
  436. Procedure fpc_ansistr_append_shortstring(Var S : AnsiString;const Str : ShortString); compilerproc;
  437. var
  438. ofs : SizeInt;
  439. begin
  440. if Str='' then
  441. exit;
  442. ofs:=Length(S);
  443. SetLength(S,ofs+length(Str));
  444. { the pbyte cast avoids an unique call which isn't necessary because SetLength was just called }
  445. JLSystem.ArrayCopy(JLObject(ShortstringClass(@Str).fdata),0,JLObject(AnsistringClass(S).fdata),ofs,length(Str));
  446. end;
  447. {$define FPC_HAS_ANSISTR_APPEND_ANSISTR}
  448. Procedure fpc_ansistr_append_ansistring(Var S : AnsiString;const Str : AnsiString); compilerproc;
  449. var
  450. ofs, strlength: longint;
  451. begin
  452. if Str='' then
  453. exit;
  454. strlength:=length(str);
  455. ofs:=Length(S);
  456. { no problem if s and str are the same string, because "var" parameters are
  457. copy-in/out for ansistring }
  458. SetLength(S,ofs+strlength);
  459. JLSystem.ArrayCopy(JLObject(AnsistringClass(Str).fdata),0,JLObject(AnsistringClass(S).fdata),ofs,strlength);
  460. end;
  461. {$define FPC_HAS_ANSISTR_COPY}
  462. Function Fpc_Ansistr_Copy (Const S : AnsiString; Index,Size : SizeInt) : AnsiString;compilerproc;
  463. var
  464. res: AnsistringClass;
  465. begin
  466. dec(index);
  467. if Index < 0 then
  468. Index := 0;
  469. { Check Size. Accounts for Zero-length S, the double check is needed because
  470. Size can be maxint and will get <0 when adding index }
  471. if (Size>Length(S)) or
  472. (Index+Size>Length(S)) then
  473. Size:=Length(S)-Index;
  474. If Size>0 then
  475. begin
  476. res:=AnsistringClass.Create;
  477. { +1 for terminating #0 }
  478. setlength(res.fdata,size+1);
  479. JLSystem.ArrayCopy(JLObject(AnsistringClass(S).fdata),index,JLObject(res.fdata),0,size);
  480. result:=ansistring(res);
  481. end;
  482. { default function result is empty string }
  483. end;
  484. {$define FPC_HAS_POS_SHORTSTR_ANSISTR}
  485. Function Pos (Const Substr : ShortString; Const Source : AnsiString) : SizeInt;
  486. var
  487. i,j,k,MaxLen, SubstrLen : SizeInt;
  488. begin
  489. Pos:=0;
  490. SubstrLen:=Length(SubStr);
  491. if SubstrLen>0 then
  492. begin
  493. MaxLen:=Length(source)-Length(SubStr);
  494. i:=0;
  495. while (i<=MaxLen) do
  496. begin
  497. inc(i);
  498. j:=0;
  499. k:=i-1;
  500. while (j<SubstrLen) and
  501. (ShortStringClass(@SubStr).fdata[j]=AnsistringClass(Source).fdata[k]) do
  502. begin
  503. inc(j);
  504. inc(k);
  505. end;
  506. if (j=SubstrLen) then
  507. begin
  508. Pos:=i;
  509. exit;
  510. end;
  511. end;
  512. end;
  513. end;
  514. {$define FPC_HAS_POS_ANSISTR_ANSISTR}
  515. Function Pos (Const Substr : AnsiString; Const Source : AnsiString) : SizeInt;
  516. var
  517. i,j,k,MaxLen, SubstrLen : SizeInt;
  518. begin
  519. Pos:=0;
  520. SubstrLen:=Length(SubStr);
  521. if SubstrLen>0 then
  522. begin
  523. MaxLen:=Length(source)-Length(SubStr);
  524. i:=0;
  525. while (i<=MaxLen) do
  526. begin
  527. inc(i);
  528. j:=0;
  529. k:=i-1;
  530. while (j<SubstrLen) and
  531. (AnsistringClass(SubStr).fdata[j]=AnsistringClass(Source).fdata[k]) do
  532. begin
  533. inc(j);
  534. inc(k);
  535. end;
  536. if (j=SubstrLen) then
  537. begin
  538. Pos:=i;
  539. exit;
  540. end;
  541. end;
  542. end;
  543. end;
  544. {$define FPC_HAS_POS_ANSICHAR_ANSISTR}
  545. { Faster version for a char alone. Must be implemented because }
  546. { pos(c: char; const s: shortstring) also exists, so otherwise }
  547. { using pos(char,pchar) will always call the shortstring version }
  548. { (exact match for first argument), also with $h+ (JM) }
  549. Function Pos (c : AnsiChar; Const s : AnsiString) : SizeInt;
  550. var
  551. i: SizeInt;
  552. begin
  553. for i:=1 to length(s) do
  554. begin
  555. if AnsistringClass(s).fdata[i-1]=c then
  556. begin
  557. pos:=i;
  558. exit;
  559. end;
  560. end;
  561. pos:=0;
  562. end;
  563. {$define FPC_HAS_ANSISTR_OF_CHAR}
  564. Function StringOfChar(c : char;l : SizeInt) : AnsiString;
  565. begin
  566. SetLength(StringOfChar,l);
  567. FillChar(AnsistringClass(result).fdata,l,c);
  568. end;
  569. {$define FPC_HAS_UPCASE_ANSISTR}
  570. function upcase(const s : ansistring) : ansistring;
  571. var
  572. u : unicodestring;
  573. begin
  574. u:=s;
  575. result:=upcase(u);
  576. end;
  577. {$define FPC_HAS_LOWERCASE_ANSISTR}
  578. function lowercase(const s : ansistring) : ansistring;
  579. var
  580. u : unicodestring;
  581. begin
  582. u:=s;
  583. result:=lowercase(u);
  584. end;