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 6095053
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:46:11+00:00 2026-05-23T12:46:11+00:00

Some string that I am getting is UTF-8 encoded, and contains some special characters

  • 0

Some string that I am getting is UTF-8 encoded, and contains some special characters like
Å¡, Ä‘, Ä etc. I am using StringReplace() to convert it to some normal text, but I can only convert one type of character. Because PHP also has a function to replace strings as seen here: how to replace special characters with the ones they're based on in PHP?, but it supports arrays:

<?php
  $vOriginalString = "¿Dónde está el niño que vive aquí? En el témpano o en el iglú. ÁFRICA, MÉXICO, ÍNDICE, CANCIÓN y NÚMERO.";

  $vSomeSpecialChars = array("á", "é", "í", "ó", "ú", "Á", "É", "Í", "Ó", "Ú", "ñ", "Ñ");
  $vReplacementChars = array("a", "e", "i", "o", "u", "A", "E", "I", "O", "U", "n", "N");

  $vReplacedString = str_replace($vSomeSpecialChars, $vReplacementChars, $vOriginalString);

  echo $vReplacedString; // outputs '¿Donde esta el nino que vive aqui? En el tempano o en el iglu. AFRICA, MEXICO, INDICE, CANCION y NUMERO.'
?>

How can I do this in Delphi? StringReplace doesn’t support arrays.

  • 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-05-23T12:46:11+00:00Added an answer on May 23, 2026 at 12:46 pm
    function str_replace(const oldChars, newChars: array of Char; const str: string): string;
    var
      i: Integer;
    begin
      Assert(Length(oldChars)=Length(newChars));
      Result := str;
      for i := 0 to high(oldChars) do
        Result := StringReplace(Result, oldChars[i], newChars[i], [rfReplaceAll])
    end;
    

    If you are concerned about all the needless heap allocations caused by StringReplace then you could write it this way:

    function str_replace(const oldChars, newChars: array of Char; const str: string): string;
    var
      i, j: Integer;
    begin
      Assert(Length(oldChars)=Length(newChars));
      Result := str;
      for i := 1 to Length(Result) do
        for j := 0 to high(oldChars) do
          if Result[i]=oldChars[j] then
          begin
            Result[i] := newChars[j];
            break;
          end;
    end;
    

    Call it like this:

    newStr := str_replace(
      ['á','é','í'],
      ['a','e','i'], 
      oldStr
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string that has some Environment.Newline in it. I'd like to strip
So I was writing some code today that basically looks like this: string returnString
I've got an application that's using string.compare(string,string) to sort some values. The thing I
I'm having some serious issues using Zend_Lucene and foreign characters like åäö. These issues
Can I simply use if(myString == nil) For some reason a string that I
I read some properties from an xml file, amongst which is a string that
Possible Duplicate: String vs StringBuilder I just revisited some of the books that I
I could use some help creating an XSL template that will take a string
Whilst refactoring some code I came across some getter methods that returns a std::string.
I'm trying to convert some strings that are in French Canadian and basically, I'd

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.