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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:52:15+00:00 2026-06-17T18:52:15+00:00

For some reason, when running mb_convert_encoding in phpunit, I am getting unexpected results. For

  • 0

For some reason, when running mb_convert_encoding in phpunit, I am getting unexpected results. For example doing the following:


var_dump( mb_convert_encoding( utf8_decode( 'ö' ), 'UTF-8' ) === 'ö' )

The above returns bool (true) under PHP-FPM, and PHP-CLI, however under PHPunit returns false, mb_convert_encoding() is doing something, it just encodes to a messed up string.

  • 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-17T18:52:16+00:00Added an answer on June 17, 2026 at 6:52 pm

    My guess is you are using a different set of mbstring ini settings. Here is one way to troubleshoot that. First in the cli you can run php -i |grep -i "mb" to see them.

    Then create a phpunit test that asserts the values are all the same. Here is mine (I only did the likely suspects):

    class MbStringTest extends PHPUnit_Framework_TestCase{
    
    function test1(){
    $this->assertEquals('UTF-8', ini_get('mbstring.internal_encoding'));
    $this->assertEquals(0, ini_get('mbstring.encoding_translation'));
    $this->assertEquals('', ini_get('mbstring.detect_order'));
    $this->assertEquals(0, ini_get('mbstring.strict_detection'));
    
    $s='ö';
    $this->assertEquals($s,mb_convert_encoding( utf8_decode( $s ), 'UTF-8' , 'ISO-8859-1'));
    }
    
    }
    

    Aside: I couldn’t get your code to work. I needed to tell it the source encoding is ISO-8859-1. I.e. auto-detection of input character set got it wrong. If you’re just looking for a quick fix and don’t care why, adding that 3rd parameter explicitly to mb_convert_encoding may be all you need.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason I'm running a blank on how to go about doing something
I'v been trying to get phpunit up and running but for some reason i'm
For some reason, the following seems to work perfectly on my ubuntu machine running
I'm doing a new install of virtualenvwrapper, and for some reason after running virtualenvwrapper.sh
For some reason on my application when running on some configuration of hard disk
For some unknown reason I'm running into a problem when passing a variable to
For some reason not al my entities are created in the database. When running
For some reason, in IE8, javascript is not running unless I reload the page
For some reason, when I press Capture while my device is connected and running
I have an embedded system running a busybox distribution and for some reason 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.