?
Solved

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

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

Expert Comment

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

Featured Post

Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

Question has a verified solution.

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

Why Shell Scripting? Shell scripting is a powerful method of accessing UNIX systems and it is very flexible. Shell scripts are required when we want to execute a sequence of commands in Unix flavored operating systems. “Shell” is the command line i…
Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
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…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

771 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