I have a file in my desktop which is a unicode format. After this file is transferred to Unix using FTP, we are seeing some special character (like rectangle box type) at the first line. The same file is saved as UTF8 (using textpad tool, selecting encode to UTF-8 option) on my desktopand and then FTP to Unix. We could see proper data content.
I tried using the following command in Unix server (We use IBM AIX), but i got error message "Converter can not open"
iconv -f <iso89> -t <utf8> oldfile > newfile
Could you please let us know how we can automatically convert the file to UTF-8 in Unix server itself.
Thanks for the reply. I have already handled replacing ^M characters in shell script. The issue with other special character (like rectangle shaped one). This character will be in the first position only in first line.
I will tell what i am doing. We get csv file from SAP server in our Unix server. This file has delimitter of tab. We need to replace tab with comma.
We have script that replaces tab with comma.
Before changing tab to comma, we opened the file from telnet and found the rectangle box in the first position in the first line.
After changing tab to comma using shell script, we opened the file from telnet and we noticed rectangle box in the first position in the first line.
When we download this file to our windows box and opened in excel by double clicking. We are seeing small small boxes and no content. If we open in notepad then we are able to see the content.
We manually removed rectangle shaped content from Unix and download into windows and opened the file in excel. This time, we are able to see the content.
We searched in google to get some help. They are telling it is something to do with encoding to UTF-8 before FTPing to Unix server. We have this capability in notepad, but we wanted to do this program without user intervention.
I still have one issue. We will receive file with encode type format ANSI and in some cases UTF-8.
If the file comes with encode type to ANSI, then using above command, we change the file to UTF-8. This is not an issue.
But if the file is comes with UTF-8 and if we run above command then the file special characters are not coming properly.
We need to run iconv command only if the file encode type is ANSI. If it is UTF-8 then we should not run iconv. How do we identify the encode of file in UNIX. Please help me in finding this.
I found the command
enca
available on Linux
In my case, i installed on CentOS 4 the rpm
enca-1.9-4.el4.rf.i386.rpm
and the command gives following output
a) on a file supposed to be in UTF-8
[root@mini figari]# enca -L none ./fr/texte_titre.html
Universal transformation format 8 bits; UTF-8
b) on a file supposed to be in ISO8859-1
[root@mini figari]# enca -L none ./en/texte_accueil.html
7bit ASCII characters
(but ideally, enca should be configured with french language to help format recognition, unfortunately, french seems not to be included )
my 2 cents