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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:09:07+00:00 2026-06-17T16:09:07+00:00

I am writing some software that takes rows from an XLS file and inserts

  • 0

I am writing some software that takes rows from an XLS file and inserts them into a database.

In OpenOffice, a cell looks like this :

Brunner Straße, Parzelle

I am using the ExcelFormat library from CodeProject.

int type = cell->Type();
cout << "Cell contains " << type << endl;
const char* cellCharPtr = cell->GetString();
if (cellCharPtr != 0) {
  value.assign(cellCharPtr);
  cout << "normal string -> " << value << endl;
}

The string when fetched with the library, is returned as a char* (so cell->Type() returns STRING, not WSTRING) and now looks like this (on the console) :

normal string -> Brunner Stra�e, Parzelle
hex string -> 42 72 75 6e 6e 65 72 20 53 74 72 61 ffffffdf 65 2c 20 50 61 72 7a 65 6c 6c 65 

I insert it into the database using the mysql cpp connector like so :

prep_stmt = con -> prepareStatement ("INSERT INTO "
                  + tablename 
                  + "(crdate, jobid, imprownum, impid, impname, imppostcode, impcity, impstreet, imprest, imperror, imperrorstate)"
                  + " VALUES(?,?,?,?,?,?,?,?,?,?,?)");

<...snip...>

prep_stmt->setString(8,vals["street"]);

<...snip...>

prep_stmt->execute();

Having inserted it into the database, which has a utf8_general_ci collation, it looks like this :

Brunner Stra

which is annoying.

How do I make sure that whatever locale the file is in gets transformed to utf-8 when the string is retrieved from the xls file?

This is going to be running as a backend for a web service, where clients can upload their own excel files, so “Change the encoding of the file in Libre Office” can’t work, I am afraid.

  • 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-17T16:09:08+00:00Added an answer on June 17, 2026 at 4:09 pm

    Your input seems to be encoded in latin1, so you need to set the mysql “connection charset” to latin1.

    I’m not familiar with the API you are using to connect to MySQL. In other APIs you’d add charset=latin1 to the connection URL or call an API function to set the connection encoding.

    Alternatively you can recode the input before feeding it to MySQL.

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

Sidebar

Related Questions

I've been working on some streaming software that takes live feeds from various kinds
I'm writing some software that requires storing items in a database, the items need
I'm writing some software that modifies a Windows Server's configuration (things like MS-DNS, IIS,
I'm writing my own software rasterizer in Java, and I ran into some trouble
I am writing some testing software that receives some source code, compiles it on
I'm writing some data acquisition software and need a gui plotting library that is
I am looking at writing some software that will allow me to listen to
I have been writing some software that uses a random string to create a
I'm writing some software to track if a file has been checked out and
I'm trying to compile some software I've been writing in Linux that uses 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.