Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2011-03-16
5
Medium Priority
?
690 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 84

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 84

Accepted Solution

by:
Dave Baldwin earned 2000 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 84

Expert Comment

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

Featured Post

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

This article discusses how to create an extensible mechanism for linked drop downs.
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
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…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.
Suggested Courses

610 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