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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:52:37+00:00 2026-05-27T00:52:37+00:00

It is unfortunate that I am running into some troubles with the php sax

  • 0

It is unfortunate that I am running into some troubles with the php sax parser and the utf-8 encoding.

The case:

I have a xml-file that is encoded in utf-8. The file is parsed using the standard php sax parser. The data is stored into some container objects and inserted into a mysql database. Unfortunately some characters look weird in the database (mostly german umlaute). For example Gürtel looks like Gürtel.

The following code fragment shows how the parser is instantiated:

$saxParser = xml_parser_create("UTF-8");

Does this suffice to parse utf-8 files? If yes, what I am missing? Some sepcial database stuff when inserting?

Thanks in advance.

  • 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-05-27T00:52:38+00:00Added an answer on May 27, 2026 at 12:52 am

    Check the encoding step by step to find the invalid code:

    1. Print the value you retrive from the XML
    2. Print out the SQL statement you build

    When printing the values, make sure your browser reads the output with the correct encoding.

    You have to ensure that every component uses the proper encoding:

    PHP script

    Save your PHP with the encoding set to UTF-8 without BOM, because this might cause problems. Use only multibyte string functions when working with UTF-8 strings.

    XML file

    XML file starts with
    <?xml version="1.0" encoding="UTF-8" ?>
    and the file is properly saved with the encoding set to UTF-8.

    SQL column (collation)

    VARCHAR(length) [CHARACTER SET charset_name] [COLLATE collation_name]
    

    Communication between MySQL server and PHP script

    Run this command right after opening the connection to the MySQL server:

    SET NAMES 'UTF8'
    

    SET NAMES indicates what character set the client will use to send SQL
    statements to the server.
    http://dev.mysql.com/doc/refman/5.0/en/charset-connection.html

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

Sidebar

Related Questions

I use a parser generator here, that unfortunately insists on putting a #include <some/file.h>
I have a jQuery selector that is running way too slow on my unfortunately
I have a simple .exe that needs to be running continuously. Unfortunately, sometimes it
I ran into an issue with some third party software that we use to
I have a navigation controller based application and I'm running into a strange issue
I am running into a strange problem and seem to have to hunted down
My Predicament: I have some things on my server that I want to connect
I'm building a set of SVG files that include an unfortunate number of hardcoded
I have a Rails application that unfortunately after a request to a controller, has
Unfortunately I've a problem with IE =( I have a service on IIS that

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.