Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8982801
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T20:40:10+00:00 2026-06-15T20:40:10+00:00

I am trying to replace character (decimal value 197) in a UTF-8 file with

  • 0

I am trying to replace character (decimal value 197) in a UTF-8 file with character (decimal value 65)

I can load the file and put it in a string (may not need to do that though)

SS := TStringStream.Create(ParamStr1, TEncoding.UTF8);
SS.LoadFromFile(ParamStr1);
//S:= SS.DataString;
//ShowMessage(S);

However, how do i replace all 197’s with a 65, and save it back out as UTF-8?

 SS.SaveToFile(ParamStr2);
 SS.Free;

————– EDIT —————-

reader:= TStreamReader.Create(ParamStr1, TEncoding.UTF8);
 writer:= TStreamWriter.Create(ParamStr2, False, TEncoding.UTF8);

 while not Reader.EndOfStream do
 begin
  S:= reader.ReadLine;
  for I:= 1 to Length(S)  do
  begin
   if Ord(S[I]) = 350 then
   begin
    Delete(S,I,1);
    Insert('A',S,I);
   end;
  end;
  writer.Write(S + #13#10);
 end;

 writer.Free;
 reader.Free;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T20:40:11+00:00Added an answer on June 15, 2026 at 8:40 pm

    Decimal 197 is hex C5, and decimal 65 is hex 41.

    C5 is not a valid UTF-8 octet by itself, but 41 is. So I have to assume you are actually referring to Unicode codepoints U+00C5 LATIN CAPITAL LETTER A WITH RING ABOVE and U+0041 LATIN CAPITAL LETTER A instead.

    U+00C5 is encoded in UTF-8 as C3 85, and U+0041 is encoded as 41. To do what you are asking, you have to decode the UTF-8, replace the codepoints, then re-encode back to UTF-8. StringReplace() will work just fine for that, eg:

    SS := TStringStream.Create('', TEncoding.UTF8);
    SS.LoadFromFile(ParamStr1);
    
    S := StringReplace(SS.DataString, 'Å', 'A', [rfReplaceAll]);
    
    SS2 := TStringStream.Create(S, TEncoding.UTF8);
    SS2.SaveToFile(ParamStr2);
    
    SS2.Free;
    SS.Free;
    

    Or:

    reader := TStreamReader.Create(ParamStr1, TEncoding.UTF8);
    writer := TStreamWriter.Create(ParamStr2, False, TEncoding.UTF8);
    
    while not Reader.EndOfStream do
    begin
      S := reader.ReadLine;
      S := StringReplace(S, 'Å', 'A', [rfReplaceAll]);
      writer.WriteLine(S);
    end;
    
    writer.Free;
    reader.Free;
    

    Update: based on other comments, it looks like you are not actually interested in Unicode codepoint U+00C5 LATIN CAPITAL LETTER A WITH RING ABOVE, but rather in U+015E LATIN CAPITAL LETTER S WITH CEDILLA instead, which is encoded in UTF-8 as C5 9E. If that is true, then simply replace Å with Ş when calling StringReplace() after the UTF-8 data has been decoded:

    S := StringReplace(S, 'Ş', 'A', [rfReplaceAll]);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to replace a single character (bit) in a string, which is
I am trying to replace the backslash (escape) character in a Javascript string literal.
I am trying to replace a certain character in a string with a space
I'm trying to replace the ^ character on a String using: String text =
I am trying to replace a character in a string with multiple occurences in
I am trying to replace the character sequence &a with So I can have
I'm trying to replace a character at a specific index in a string. What
I'm trying to replace a special character (^) in javascript with string.replace but am
I am trying to replace the nth occurrence of a character or string regardless
I am trying to replace every character from a string with it's opposite but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.