Delphi
--
Questions
--
Followers
Top Experts
How do I then find these special characters, and replace them with say an empty string? I'm aware of how to do this with normal String variables, but how can it be achieved with PWideChar variables?
Your assistance will be much appreciated please. Thanks!
Zero AI Policy
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
use this numbers to handle the characters. From a paragraph you can search for a character with it's unique decimal code points. So that you can easily handle them.
I will also suggest you to use WideChar(parameter as a num); for better results.
Here you can convert the characters to their unicode specific nos.
http://people.w3.org/rishi
Thanks for your suggestions. The issue I'm facing now is manipulating the PWideChar variable itself. I'm quite new with Delphi, and even newer with the PWideChar type. I'm therefore looking for a reference with which can be used to manipulate PWideChar variables, much like how String variables can be manipulated i.e. the methods, properties etc.






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
Delphi handles typecasting from a Widestring to a PWideChar as long as you tell it to...
regards
Hypo
uses ..., StrUtils;
procedure TForm1.Button1Click(Sender: TObject);
var aWideChar : PWideChar;
aTempString : WideString;
begin
// Load the PWideChar-string with some data...
aWideChar := '123:321';
// Move the PWideChar-string into a temp-string...
aTempString := aWideChar;
// Do your stuff...
aTempString := ReplaceStr(aWideChar, ':', ' ');
// Reload the PWideChar with the contents of the string...
aWideChar := PWideChar(aTempString);
// Show results...
ShowMessage(aWideChar);
end;
I tried the following:
var
tempName: WideString;
newName: PWideChar
...
newName := PWideChar(TntMemo1.Lines.S
tempName := newName;
tempName := StringReplace(newName, ':', ' ');
newName := PWideChar(tempName);
But when I tried to show the results within another TNTMemo object, the Chinese characters have all been converted to "?"s. I think this occured when the PWideChar variable is changed to the WideString type (i.e. tempName := newName).
I noticed that u used the "ReplaceStr" method, what do I need to add to the "Uses.." statement to use this method?

Get a FREE t-shirt when you ask your first question.
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
Everything seems to work fine for now.
function SplitString(pos: Integer; str: WideString): WideString;
var
left: WideString;
right: WideString;
begin
left := LeftStr(str, pos-1);
right := RightStr(str, Length(str)-pos);
Result := left + right;
end;
Delphi
--
Questions
--
Followers
Top Experts
Delphi is the most powerful Object Pascal IDE and component library for cross-platform Native App Development with flexible Cloud services and broad IoT connectivity. It provides powerful VCL controls for Windows 10 and enables FMX development for Windows, Mac and Mobile. Delphi is your choice for ultrafast Enterprise Strong Development™. Look for increased memory for large projects, extended multi-monitor support, improved Object Inspector and much more. Delphi is 5x faster for development and deployment across multiple desktop, mobile, cloud and database platforms including 32-bit and 64-bit Windows 10.