Solved

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

Posted on 2011-03-16
5
664 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
  • 3
  • 2
5 Comments
 
LVL 82

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 82

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 82

Expert Comment

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

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…

760 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now