Solved

How to convert a UTF-8 file to ASCII file and retain special characters?

Posted on 2011-03-16
5
672 Views
Last Modified: 2012-05-11
I have a UTF-8 file that contains English and Spanish text. The Spanish text uses characters like a tilde. Additionally, the text contains copyright and trademark symbols.

I need to convert the file to ASCII format to use import into a new application. I tried converting the file in Linux like this but the resulting file is striped off all special characters:

iconv --from-code UTF-8 --to-code US-ASCII -c originalfile.txt > newfile.txt

I can also convert the file in the PHP application before generating (if easier).

Any ideas?
0
Comment
Question by:bearclaws75
[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
5 Comments
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 35152756
US-ASCII simply doesn't have those characters.  http://en.wikipedia.org/wiki/ASCII
0
 

Author Comment

by:bearclaws75
ID: 35152844
I can live without the Spanish text but what about the copyright and trademark symbols; however, I don't see those listed in the ASCII charts either:
http://en.wikipedia.org/wiki/File:ASCII_Code_Chart.svg

Is there any ASCII format that can handle these characters or do I need to use another character format?
0
 
LVL 83

Accepted Solution

by:
Dave Baldwin earned 500 total points
ID: 35152928
You need to use another format.  ASCII is just the 7-bit characters.  ISO-8859-1 might be the first choice but ANSI is also known as Windows-1252 character set.  http://www.alanwood.net/demos/charsetdiffs.html
0
 

Author Closing Comment

by:bearclaws75
ID: 35156550
Thanks! This is very helpful.
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 35158632
You're welcome.  Thanks for the points.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

737 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