Модератор: Модераторы
Have a look to FPC StringReplace() function in rtl/objpas/sysutils/systr.inc.
Trunk 4286 has replacestring() function, experimental, please test.
"
S1:='<text:text-input
text:description="Фамилия">$Фамилия$</text:text-input>';
se1.Value:=S1;
se2.Value:=UTF8ToString(S1);
"
Doesn't work,
"
'<text:text-input
text:description="Фамилия">$Фамилия$</text:text-input>'
"
will be converted utf-8 -> utf-16 on compiletime and converted utf-16 ->
current system encoding on runtime by the unicodestringmanager.
"
S1:='<t...
"
Coneversion current system encoding -> utf-16 on runtime by the
widestringmanager.
"
se1.Value:=S1;
"
So either use all msestring and msestring version of replacestring():
"
var
S1, S2 : msestring;
begin
S1:='<text:text-input
text:description="Фамилия">$Фамилия$</text:text-input>';
se2.Value:=S1;
se3.Value:=ReplaceString(S1, '$Фамилия$', 'Иванов');
"
or all utf-8 ansistring, now FPC ansi StringReplace() can be used:
"
var
S1, S2 : string;
begin
S1:= stringtoutf8('<text:text-input
text:description="Фамилия">$Фамилия$</text:text-input>');
se2.Value:= utf8tostring(S1);
se3.Value:= utf8tostring(StringReplace(S1,stringtoutf8('$Фамилия$'),
stringtoutf8('Иванов'),[]));
"
> Lower: there's should be nothing replaced.
Should be fixed in trunk 4265, there was a wrong parenthesis.
Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 27