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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T00:01:51+00:00 2026-06-18T00:01:51+00:00

I have a database which uses latin-1 and a PHP application which is utf-8.

  • 0

I have a database which uses latin-1 and a PHP application which is utf-8.

I have strings in the database like this:

‘Société‘ which should be Société

‘€1bn‘ which should be €2bn.

When I print the faulty characters to screen with PHP’s ord(), from the returning data in the db, it prints 195 and 226.

Could somebody explain why this is happening (why saving like this and why characters being read as they are) and if I can reverse it.

  • 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-18T00:01:52+00:00Added an answer on June 18, 2026 at 12:01 am

    The WHY:

    1) é is unicode 233 (as the browser reads it).
    é utf8 bytes converted into latin1 chars bytes is à ©. This is why it appears like this in the database.
    à © is recognised as à which is code point 195. Hence why you see that.

    2) € is unicode 8364.
    € utf8 bytes converted into latin1 chars bytes is â <82> ¬. Again this is why they appear like this in the db.
    â <82> ¬ is recognised as â which is code point 226. Again this is why you see this.

    That is why you see those values from ord() and why the characters are stored in that manner in a latin-1 database.

    Reverse:

    To reverse it we need Latin-1 char bytes to UTF8 bytes.

    If we try it:
    â is 226. Converted latin-1 to utf8 produces â.
    à is 195. Converted latin-1 to utf8 produces Ã.

    Problem:

    The problem is Latin-1 has less characters than utf-8 (by a long way).
    Latin1 single-byte stream and UTF8 multi-byte char stream so 1 char in utf8 could produce up to 4 chars for latin1.
    So the UTF-8 to Latin-1 conversion produces faulty characters.
    Latin1 back to utf8 is not possible.

    Solution:

    IF you are unable to change the character set of your database I could suggest encoding special characters in the database in their character entity before writing them (so the db can stay as latin1 and app as utf8 as both can understand html entities) e.g. umlaut as &Auml;.
    It could be done using PHPs html_entity_decode() combined with mb_detect_encoding() to detect and convert specific characters.

    References:

    See ltf.ed.ac.uk for the utf8 char bytes to latin1 bytes:
    http://www.ltg.ed.ac.uk/~richard/utf-8.cgi?input=%C3%96&mode=char

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

Sidebar

Related Questions

I have heard that when developing application which uses a database you should do
I have this Java application which uses a MySql Database which I want to
I currently have an application which uses EF database first which was built against
I have three websites which uses an abstract database structure with tables like: Items,
I'm working on an application which uses SQLite Database on Android.I have a custom
I have a WPF application which uses a (currently) local database to act as
Hi i have a database application which uses registered modules. Modules are registered via
I have written a module for a PHP IRC bot which uses a database
I have implemented an App which uses SQLite database, now if I run the
I have a procedure which uses 2 sql databases - this is required in

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.