First letter from UTF8 string lazarus / 13-General ---------------------------------------------------------------------- katyan · 2009-01-27 21:12 Hi, I'm using Lazarus 0.9.26 on Windows XP. I want to get first letter from UTF8 - how to do that? Also, I want to Upcase all character than user input into EditBox. Any ideas? Thanks for reply. ---------------------------------------------------------------------- Vincent Snijders · 2009-01-27 21:16 Use Utf8Copy. FirstChar := Utf8Copy(s,1,1); ---------------------------------------------------------------------- theo · 2009-01-27 22:07 Quote from: katyan on January 27, 2009, 10:12:29 pmAlso, I want to Upcase all character than user input into EditBox. Any ideas? http://lazarus-ccr.sourceforge.net/docs/lcl/lclproc/utf8uppercase.html ---------------------------------------------------------------------- katyan · 2009-01-28 21:02 OK. Thanks Vincent - Utf8Copy will help, but is it possibile to do things like this: s:string; ch:TUTf8Char; s[1]:=UTF8UpperCase(UTF8Copy(s,1,1)); ?? I want to capitalize only first letter of string. And about upcase all character in Tedit. I want to UpCase character while typing. So in OnKeyPress event: procedure TPWorkersForm.AllKeyUp(Sender: TObject; var Key: char); begin   key:=UpperCase(Key); end;    But it doesn't work with Utf8 so I tried... (it doesn't work too) procedure TWorkerForm.Edit4UTF8KeyPress(Sender: TObject; var UTF8Key: TUTF8Char ); begin   UTF8Key:=UTF8UpperCase(UTF8Key); end; ---------------------------------------------------------------------- Vincent Snijders · 2009-01-28 21:06 Such thing should be possible, but I did not test and try it. By the way, why don't you use ecUppercase. ---------------------------------------------------------------------- theo · 2009-01-28 21:35 Quote from: katyan on January 28, 2009, 10:02:48 pm I want to capitalize only first letter of string. Sometimes it's easier to convert to WideString for such operations. This should do what you need: Code: [Select]function UTF8UpperFirst(Value:UTF8String):UTF8String; var temp:WideString; begin   temp:=UTF8Decode(Value);   if length(temp) > 0 then temp[1]:=WideUpperCase(temp[1])[1];   Result:=UTF8Encode(temp); end; ---------------------------------------------------------------------- katyan · 2009-01-28 22:29 Thanks guys! Now all works great!