Solved

Replacing accent characters when reading writing csv files

Posted on 2008-10-10
6
1,621 Views
Last Modified: 2013-11-07
I am reading "certain" field values from several different csv files and combining these files into 1 csv file.  I have to format the values slightly before I add them to my master csv file because it will eventually be imported into SQL at a later date, mainly I just need to truncate the values so that the SQL import process won't complain.

The problem I am running into is when a value has accent characters.  For instance I have a value of
LA CITÉ.  So one of the things I do is replace É with E and if I MessageBox this, it works just as expeced.  However when I look at the master file after all the files have been processed, the value that actually got saved is LA CITÃ0 rather than LA CITE.

Any idea why this is happening and what I can do about it?  I am on .NET 1.1
0
Comment
Question by:GaryRasmussen
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 1

Author Comment

by:GaryRasmussen
ID: 22688402
I was wondering how those characters would show up in the question.  Where it says LA CITA0 in the last line, the A in CITA actually has a tilde over the top of it and the 0 in CITA is actually a fraction 0/00

Thanks!
0
 
LVL 3

Expert Comment

by:3abqari
ID: 22688510
I think that will depend on the Character Encoding tag that you put in the html:

<meta http-equiv="content-type" content="text/html; charset=UTF-8">

I don't know exactly how you change it in C#'s .ascx or aspx files.
0
 
LVL 1

Author Comment

by:GaryRasmussen
ID: 22688542
The HTML?  This is a csv to csv import/export.  It is never rendered to HTML
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Expert Comment

by:3abqari
ID: 22688557
Yeah... sorry about that... my bad.
0
 
LVL 26

Expert Comment

by:Anurag Thakur
ID: 22689012
is the following link going to be of any help to you
http://blogs.msdn.com/michkap/archive/2005/02/19/376617.aspx
0
 
LVL 1

Accepted Solution

by:
GaryRasmussen earned 0 total points
ID: 22689105
Thanks,

I read that one last night.  Unfortunately NormalizedString is only avaialble in .NET 2.0 and my application is .NET 1.1

I think the main issue here is that even when I look at the data in say Notepad and it looks like an E with an accent over the top of it, that is not neccessarily what the actual characters are because when the datatable reads the same value, it reads it as having other characters so there is no way to determine ahead of time what the actual string value is.

What is worse is that using substring to truncate the string doesn't work either because it treats the 4 chars that make up the single char as 1 character so the string does not get truncated to the correct length.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question