Cygwin vi XML file encoding problem


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Cygwin vi XML file encoding problem
# 1  
Old 07-23-2010
Cygwin vi XML file encoding problem

Hi,

I have got a zip (binary) file transferred from MacOS (thus it has additional __MACOSX directory packed inside). On extracting this zip, there are few *.xml files available. When I opened this *.xml file in vim editor using Cygwin (on windows) the editor displayed [Incomplete last line][converted] in the bottom. I tried command file command on this xml file gave me the result "Big-endian UTF-16 Unicode character data".

After google search I came to know Mac's line terminator is carriage return '\r'. So windows needs '\r\n' (carriage return + line feed). So I manually added this \n using sed command
Code:
sed -i 's/$/\r\n/' test.xml

After that I am seeing the output as:

Code:
þÿ^@<^@?^@x^@m^@l^@ ^@v^@e^@r^@s^@i^@o^@n^@=^@"^@1^@.^@0^@"^@ ^@e^@n^@c^@o^@d^@i^@n^@g^@=^@"^@U^@T^@F^@-^@8^@"^@?^@>^@^M

How to make this file a valid XML document?

Last edited by royalibrahim; 07-23-2010 at 12:52 PM..
# 2  
Old 07-23-2010
What is your question for the forum?
# 3  
Old 07-27-2010
My question to the forum is, how to convert this file to a valid XML document type (removing UTF-16 format and make it look like an ordinary file)
# 4  
Old 07-27-2010
UTF-16 is a valid XML encoding for a document. Line terminators between elements are not part of the XML standard per se. So long as the document is well-formed, it is valid.

I suspect that what you want to do is to convert the document into a more viewable format i.e. UTF-8 If this is the case, have a look at the iconv man page.
# 5  
Old 07-28-2010
I have attached the file here "sample.xml". Please have a look at it

As you have told I have used the 'iconv' command as follows
Code:
iconv -f UTF-16LE -t  UTF-8 < sample.xml

but not working as expected....

I need your help.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to know file encoding?

how can i know what format a file is * example: UTF-8 ANSI UCS2 i am in a... (8 Replies)
Discussion started by: tricampeon81
8 Replies

2. Solaris

View file encoding then change encoding.

Hi all!! I´m using command file -i myfile.xml to validate XML file encoding, but it is just saying regular file . I´m expecting / looking an output as UTF8 or ANSI / ASCII Is there command to display the files encoding? Thank you! (2 Replies)
Discussion started by: mrreds
2 Replies

3. Shell Programming and Scripting

Use curl to send a static xml file using url encoding to a web page using pos

Hi I am try to use curl to send a static xml file using url encoding to a web page using post. This has to go through a particular port on our firewall as well. This is my first exposure to curl and am not having much success, so any help you can supply, or point me in the right direction would be... (1 Reply)
Discussion started by: Paul Walker
1 Replies

4. Shell Programming and Scripting

Xmllint - Xml-file problem --ods file not opening

Dear All, this is my first post on this Forum, glad to be here. I'm trying to fix an .ods file. Yes, I had a backup, but it's also corrupted. When opening the document I get this EM: read error format error discovered in the file in sub-document content.xml at 2,337040(row,col). So I... (3 Replies)
Discussion started by: jameslast
3 Replies

5. Programming

problem with accessing online XML file

Hi everyone, I am trying to access an online XML file, for example: <a href="http://www.rgraph.net/sample.xml" target="_blank">http://www.rgraph.net/sample.xml using HTML. <html> <body> <script type="text/javascript"> if (window.XMLHttpRequest) {// code for IE7+, Firefox,... (1 Reply)
Discussion started by: Xperia124
1 Replies

6. Shell Programming and Scripting

How to achieve UTF-8 encoding & URL escape in an xml file?

Is there any i can achieve entity escaping, URL escaping & UTF-8 encoded for the xml generated through shell script? #! /bin/bash echo "<path>" >> file.xml for x in `ls filename*` do echo -e "\t<dir>" >> file.xml echo -e "\t\t<file>$x</file>" >> file.xml... (0 Replies)
Discussion started by: vel4ever
0 Replies

7. Solaris

Encoding problem

Hi All, Hope you can help me with the below :). I'm working on a script on SUN solaris and I'm facing a problem with the number encoding as shown below, 1 is encoded to 31 (this is ASCII so it's ok) 11 is encoded as B118 !!! don't know why 111 is encoded as B1580C !!! don't know why ... (4 Replies)
Discussion started by: /dev/bag
4 Replies

8. Shell Programming and Scripting

How to find the file encoding and updating the file encoding?

Hi, I am beginner to Unix. My requirement is to validate the encoding used in the incoming file(csv,txt).If it is encoded with UTF-8 format,then the file should remain as such otherwise i need to chnage the encoding to UTF-8. Please advice me how to proceed on this. (7 Replies)
Discussion started by: cnraja
7 Replies

9. AIX

get the file encoding

Hello! The system is AIX 5.3 Give please command or script to get the file encoding (1 Reply)
Discussion started by: vinment
1 Replies

10. Shell Programming and Scripting

Problem printing the property of xml file via shell script

Hi, I have a config.xml which cointains the tags like <CONFIG> <PROPERTY name="port" value="1111"/> <PROPERTY name="dbname" value="ABCDE"/> <PROPERTY name="connectstring" value="xyz/pwd"/> </CONFIG> This file is in some directory at UNix box. I need to write a... (4 Replies)
Discussion started by: neeto
4 Replies
Login or Register to Ask a Question