File enconding and conversion


 
Thread Tools Search this Thread
Operating Systems AIX File enconding and conversion
# 1  
Old 05-29-2013
IBM File enconding and conversion

Hi

am not a specialist about file encoding.
On an AIX 5.2.0.0, I need to check files encoding and convert somes of them to UTF-8.

I've used the following command and i think it said to me that all files are encoded using ISO8859-1
Code:
%locale charmap
ISO8859-1

I've also used iconv command that way :
Code:
iconv -f ISO8859-1 -t UTF-8 test.txt > test2.txt

Is there any command to check that test.txt is in ISO8859-1and test2.txt in UTF-8 ?

Thank You
# 2  
Old 05-29-2013
The procedure looks correct. However, I do not know of any verification process.
# 3  
Old 05-29-2013
The command locale charmap is telling you (by convention) that the character mapping defining the characters in your current locale is related to ISO standard 8859-1. It says absolutely nothing about what codeset was used to encode text found in any particular file.

If a file only contains ASCII text, the ISO8859-1 and the UTF-8 encoding will be identical. If there are characters in a file with the high order bit set on one or more bytes, there are various heuristics you could try to use to determine if a given file was encoded using a particular codeset, but heuristics that could distinguish between various ISO 8859-* standard encodings would require more knowledge than just the contents of the file. Even determining that a file was encoded using UTF-8 would be impossible unless you know that the file only contains text (i.e., no binary data such as an integer or floating point value has been written into the file without converting it to text first).

The only way to use iconv to reliably convert a file from one codeset to another is to know (independently) what codeset was used when the file was created and what transformations have occurred to that file since then. If the file being converted contains some binary values and some text, you will have to know where the binary data is and just convert the text surrounding the binary data. (You can't do this with iconv, but you could use something like dd to extract the text and binary data into separate files, use iconv to convert the text files, and then create the converted output by putting the converted text files and the binary files back together. Of course, converting from 8859-* to or from UTF-8 can also significantly change the number of bytes needed to represent a string of text. If the data in the file contained binary data specifying the length of some of the text in the file, you would have to also be aware of that and modify the binary portions of the file as well as you reconstruct the output file.)
This User Gave Thanks to Don Cragun For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Linux

File conversion and removing special characters from a file in Linux

I have a .CSV file when I check for the special characters in the file using the command cat -vet filename.csv, i get very lengthy lines with "^@", "^I^@" and "^@^M" characters in between each alphabet in all of the records. Using the code below file filename.csv I get the output as I have a... (2 Replies)
Discussion started by: dhruuv369
2 Replies

2. Shell Programming and Scripting

file conversion

Hi, I have an excel file in unix and I want a script which changes the excel file to .csv file i.e (comma separated value file). Would be thankful to you if some one helps me with this. Thanks in advance. (3 Replies)
Discussion started by: karthikkasarla
3 Replies

3. Shell Programming and Scripting

Conversion of spaces Text file into CSV format file

Input file (each line is separaed by spaces )given below: Name Domain Contact Phone Email Location ----------------------- ------------------------------------------------ ------- -----... (18 Replies)
Discussion started by: sreenath1037
18 Replies

4. Shell Programming and Scripting

Conversion of below Tabs Tex file into CSV format file : shell script needed

Request if some one could provide me shell script that converts the below "input file" to "CSV format file" given Name Domain Contact Phone Email Location ----------------------- ------------------------------------------------ ------- ----- ---------------------------------... (7 Replies)
Discussion started by: sreenath1037
7 Replies

5. Shell Programming and Scripting

shell or perl script needed for ldif file to text file conversion

This is the ldf file dn: sdcsmsisdn=1000000049,sdcsDatabase=subscriberCache,dc=example,dc=com objectClass: sdcsSubscriber objectClass: top postalCode: 29600 sdcsServiceLevel: 10 sdcsCustomerType: 14 givenName: Adelia sdcsBlackListAll: FALSE sdcsOwnerType: T-Mobile sn: Actionteam... (1 Reply)
Discussion started by: LinuxFriend
1 Replies

6. Shell Programming and Scripting

File conversion

Hi Everyone, Can someone plesae advise on converting the inputted file into required output? First field is L then amount will - symbol. Sample input file B|T|SASOFTB00016|20090330|20090330|15000|9089001 B|T|SABH00000012|20090330|20090330|7000|9089003... (4 Replies)
Discussion started by: gehlnar
4 Replies

7. Shell Programming and Scripting

File Conversion

Hi all, How can i convert a file from one encoding to another? Lets say I have a file which is of utf-8 encoding and I want to convert it to cp875. Can anyone tell me how can I achieve this in shell script? Thanks, Sridhar (2 Replies)
Discussion started by: sridhar_423
2 Replies

8. Programming

C File Permission Conversion

I'm new to C, and I'm attempting to write a script similar to the stat command for practice. I only had a problem converting st_mode to an octal permission format. I remembered I had littleutils installed which contains a script called filemode, so I checked the source and it yielded something like... (4 Replies)
Discussion started by: petebear
4 Replies

9. Solaris

COnversion utility xhtml file to Postscript file

Hi, Can any suggest me some utility to convert xhtml file to postscript file format? Also tell me from where to down load such utility.. With Regards, Dattatray (0 Replies)
Discussion started by: dattatray.b
0 Replies

10. UNIX for Dummies Questions & Answers

file conversion

How can I suppress the 0a (line feed) in a text file (HP UX) (1 Reply)
Discussion started by: hipo
1 Replies
Login or Register to Ask a Question