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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:07:44+00:00 2026-06-17T11:07:44+00:00

I am unable to compare two unicode characters that to my mind should be

  • 0

I am unable to compare two unicode characters that to my mind should be exactly the same. I suspect that somehow they are encoded differently, but don’t know how to change them to the same encoding.

The characters I want to compare are from the Myanmar Unicode block. I’m running wordpress on php 5 and am trying to make a custom plugin to handle Myanmar Unicode. All my files are encoded in UTF-8, but I don’t know what wordpress does.

Here is what I’m doing:

function myFunction( $inputText ) {
    $outputText = '';
    $inputTextArray = str_split($inputText);
    foreach($inputTextArray as $char) {
        if ($char == "က") // U+1000, a character from the Myanmar Unicode block 
            $outputText .= $char;
    }
    return $outputText;
}
add_filter( 'the_content', 'myFunction');

At this stage in working things out, the function is supposed to only return က where it appears in the content. However, it never returns anything but empty strings, even when က is clearly present in the post content. If I change the character to any latin characters, the function works as expected.

So, my question is, how do I encode these characters (either $char or "က") so that when $char contains this character, they compare equal.

  • 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-17T11:07:47+00:00Added an answer on June 17, 2026 at 11:07 am

    str_split is not unicode aware. For multibyte characters it’ll split the them in single character. Try to use either multi-byte string functions or preg_split with /u switch

    $inputTextArray = preg_split("//u", $inputText, -1, PREG_SPLIT_NO_EMPTY);
    

    http://codepad.viper-7.com/ErFwcy

    Using multi-byte function mb_substr_count you can reduce your code too. Like this,

    function myFunction( $inputText ) {
        return str_repeat("က", mb_substr_count($inputText, "က"));
    }
    

    Or using regular expression,

    preg_match_all("/က/u", $text, $match);
    $output = implode("", $match[0]);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am unable to compare two non-ascii strings, although both the strings appear the
All, I currently have two projects that are under SourceSafe that I am unable
In some PHP I need to compare two strings, but only on the bits
i have mathematical problem which I'm unable to convert to PHP or explain differently.
I am getting two different count values for same string $val1 = $data->sheets[0]['cells'][5][1];//thise value
I have a page that visually has two fields right on top of each
I have a Java program running on two computers that are both on the
How does ZeroC ICE compare to 0MQ? I know that 0MQ/Crossroads and DDS are
What I need to do is compare two strings and mark the differences with
I want to compare two array indices, for (int i=0; i<[CustomeDateArray count]; i++) {

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.