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

  • Home
  • SEARCH
  • 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 8016095
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T20:26:48+00:00 2026-06-04T20:26:48+00:00

I have some serious problem dealing with files in php with utf-8 encoding. I

  • 0

I have some serious problem dealing with files in php with utf-8 encoding. I need to read a file char by char or possibly line by line, with fixed small chunks.
I tried to use fgetc and fgets but characters encoded in utf8 are split in a few “chars” instead of only one. I’m trying to find a solution, it could be even a small “string” containing only the character in Unicode but it must be read from file properly.

Pseudo code I would like to use:

while ( ($c == read_utf8_char($file)) != false ) {
    if ($c == 'ó') do_something();
}

I would appreciate your help.

  • 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-04T20:26:49+00:00Added an answer on June 4, 2026 at 8:26 pm
    function mb_str_split($string) { 
        return preg_split('/(?<!^)(?!$)/u', $string ); 
    } 
    
    $chars = mb_str_split($file);
    
    foreach ($chars as $c) {
        if ($c == 'ó') do_something();
    }
    

    ~ Source: http://www.php.net/manual/en/function.mb-split.php#99851

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

Sidebar

Related Questions

I have some files that are uuencoded, and I need to decode them, using
I have got a serious problem running our web app in some machines.. machines
I have some serious (or better say: strange ) issues with the HTTP-header: Content-Encoding.
Hi people I have a serious problem at hand, I need to know about
I have some files stored at amazon. all in private mode, and since I
I have some interesting problem for an hour.. In my flex project, all width
I have this serious problem. I have an enumeration within 2 namespaces like this:
I have a serious problem with calculating Standard Deviation within subgroup in SSRS/SQl (whichever
I am having some serious trouble with getView in a ListView. The problem is,
I am stuck here and need some serious help. I had to do some

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.