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

The Archive Base Latest Questions

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

I have an application for reading email from a webmail and saving the data

  • 0

I have an application for reading email from a webmail and saving the data in a database. I am using the PHP’s imap library to do most of the work.

The problem is that most emails have more than one charset (mostly ISO-8859-1 and UTF-8), so I have to read the charset from email and I decode it to ISO-8859-1 using the iconv function.

It works fine for most charsets, but when I read the Windows-1252 charset and try to decode it the iconv function isn’t returning anything.

If I try to change the iconv function to the mb_convert_string, it doesn’t convert all of the characters correctly.

this is my code:

if( $part->parameters[$i]->attribute == 'charset' )
    $charset =  $part->parameters[$i]->value;

if (strtolower($charset) != 'iso-8859-1')
    $this->emailMessageTxt = iconv($charset, 'iso-8859-1', $this->emailMessageTxt);

Is there an error in there?

  • 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-15T11:51:46+00:00Added an answer on June 15, 2026 at 11:51 am

    Yes, you are trying to convert from any other charset to ISO-8859-1. ISO-8859-1 cannot represent many characters at all, for example it cannot represent the character €.

    You should have been working the other way around, converting everything non-UTF-8 to UTF-8, which can represent any character on the planet.

    If you want to ignore characters that cannot be represented, just do:

    $utf8 = "€€€ money"; //My php files are saved in utf-8, don't mind that
    
    $iso8859 = iconv( "UTF-8", "ISO-8859-1//IGNORE", $utf8 );
    
    echo $iso8859; // " money"
    

    That is, convert to "ISO-8859-1//IGNORE"

    Docs:

    out_charset The output charset.

    If you append the string //TRANSLIT to out_charset transliteration is
    activated. This means that when a character can’t be represented in
    the target charset, it can be approximated through one or several
    similarly looking characters. If you append the string //IGNORE,
    characters that cannot be represented in the target charset are
    silently discarded. Otherwise, str is cut from the first illegal
    character and an E_NOTICE is generated.

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

Sidebar

Related Questions

I have a MVC application that reads some data from a database and loads
I have an application reading some data from the event log, this application performance
I'm sort of lost on this. I have an application that is reading from
I have an application where I am reading and writing small blocks of data
I have an application build in C# for reading and saving SMS and MMS,
we have to application servers, both reading from the same JMS server, preferably from
I have made an application (for my self) for feeds reading, using SyndicationFeed ,
I am using Codeigniter to develop an application, and have been reading bits about
When using SSIS to load data from a source table, we have a OLE
I have an application that will be reading sequenced packets from a udp connection.

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.