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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:00:40+00:00 2026-05-26T05:00:40+00:00

I have website that’s in win-1251 encoding and it needs to stay that way.

  • 0

I have website that’s in win-1251 encoding and it needs to stay that way. But I also need to be able to echo few links that contain non latin, non cyrillic characters like šžāņūī…

I need a function that convert this

"māja un man tā patīk"

to

"māja un man tā patīk"

and that does not touch html, so if there is <b> it needs to stay as <b>, not &gt; or &lt;

And please no advices about the encoding and how wrong that is.

  • 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-26T05:00:41+00:00Added an answer on May 26, 2026 at 5:00 am
    $str = "<b>Obāchan</b> おばあちゃん";
    
    $str = preg_replace_callback('/./u', function ($matches) {
        $chr = $matches[0];
        if (strlen($chr) > 1) {
            $chr = mb_convert_encoding($chr, 'HTML-ENTITIES', 'UTF-8');
        }
        return $chr;
    }, $str);
    

    This expects the original $str to be UTF-8 encoded, i.e. your PHP file should be saved in UTF-8. It encodes all non-ASCII compatible code points to HTML entities. Since all HTML special characters are ASCII characters, they remain untouched. The resulting string is pure ASCII. Since the lower Win-1251 code points are ASCII compatible, the resulting string is also a valid Win-1251 string. The above $str converts to:

    <b>Ob&#257;chan</b> &#12362;&#12400;&#12354;&#12385;&#12419;&#12435;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a website that tells the output is UTF-8, but I never make
I have a website that needs to perform a certain backend function once per
I have website that use XMLHttpRequest (jQuery, actually). I also have another site running
I have a website that allows a functionality for any user but each user
I have a website that I want to conduct testing on. All you need
I have a website that I need to update which is written in asp.
We have a website that allow firmware downloads. Somwhere along the way it uses
I have a website that runs smoothly, but I just saw that when I'm
I have website that will both post to a user's Facebook wall, and allow
So basically I have website that has names of cities that can be checked

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.