473,396 Members | 1,900 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Cannot change encoding at a XML with php

200 100+
I have an xml written in a file. I want in the 1st line
<?xml version="1.0" encoding="iso-88-59-7"?>
to change the encoding to utf-8 any easy way to do that?
Nov 11 '08 #1
5 3052
8,658 Expert Mod 8TB
code tag is [code] not <code> or use the button with the "#" symbol

the solution depends on which language you want to use for that (possibilities: any (server) scripting lanuage (C, Java, PHP, ASP, Perl,...), even XSLT)

Nov 11 '08 #2
200 100+
I have this XML
Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="iso-8859-7"?>
  2. <asx version="3.0" >
  3. <title>General Music ASX playlist</title>
  4. <moreinfo href="http://www.generalmusic.com"/>
  6. <entry>
  7. <title>8.07409|1.00922|ΚΡΑΤΗΣΕ ΜΕ ΣΤΟ ΡΥΘΜΟ|9.00402||8.00|</title>
  8. <ref href="UserFiles/songs/03/8.07409.mp3" />
  9. <param name="image" value="UserFiles/Image/1.00922.jpg" />
  10. </entry>
  11. <entry>
  12. <title>8.07410|1.00922|ΚΡΑΤΗΣΕ ΜΕ ΣΤΟ ΡΥΘΜΟ|9.00402||8.00|</title>
  13. <ref href="UserFiles/songs/03/8.07410.mp3" />
  14. <param name="image" value="UserFiles/Image/1.00922.jpg" />
  15. </entry>
  16. </asx>
and I want to change the encoding to utf-8 when I download it and by hand change the encoding,save it and upload it all is good.
I created a php script to automate the process which is here
Expand|Select|Wrap|Line Numbers
  1. $id=$_SESSION['id'];
  3.     $file = fopen("../player/".$id.".xml","r");
  4.     $msg=fread($file,filesize("../player/".$id.".xml"));
  5.     fclose($file);
  7.     //$msg=str_replace("iso-8859-7","utf-8",$msg);
  8.     $file = fopen("../player/".$id.".xml","w");
  9.     fwrite($file,$msg);
  10.     fclose($file);
but then all the greeks in the xml (those in the title tag) gets destroyed any help on how can I do that?
Nov 11 '08 #3
8,658 Expert Mod 8TB
I think you have to actually encode the content to utf-8. use utf8_encode().

Nov 11 '08 #4
200 100+
OK found it before writing to the file I used iconv to change the string to utf-8
Thanks for your time!
Nov 11 '08 #5
8,658 Expert Mod 8TB
never mind. I'm glad I could help.
Nov 11 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

by: Ann | last post by:
Hi, Is there any way to Change encoding of Java Vm to ISO-8859-1? i am using Java vm along with an application called opencms. I get the following error message.. Error: the encoding of your...
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- ...
by: Alexander Cohen | last post by:
How would i go about changing a databases encoding? Is this at all possible? There does not seem to be much i can with ALTER DATABASE except change its name! -- Alexander Cohen...
by: Marc | last post by:
Hi! I'm working with a C# client that calls a php web service. I've created a wrapper to call the service using .NET wsdl tool (adding a web reference). The call to the server works fine, it...
by: Jason Chan | last post by:
Some chinese characters data (in Big5 encoding) is stored in database. I tried to display the data in an aspx but the characters cannot display correctly. I tried anything I think is related: -...
by: jcsnippets.atspace.com | last post by:
Hi everyone, Recently I have posted a question regarding special characters in text files. I was trying to read the text file to process the text later on, but I was using the wrong encoding....
by: TomislaW | last post by:
I am sending word document with e-mail from asp.net 2.0 application. I read doc file like this:FileStream fs = System.IO.File.Open(docPath,FileMode.Open,FileAccess.Read,FileShare.Read); Then...
by: Diego F. | last post by:
Hi. I'm using that code: If File.Exists(Ls_NombreFichero) = False Then sw = File.CreateText(Ls_NombreFichero) Else sw = File.AppendText(Ls_NombreFichero) End If I need to change the...
by: ajmastrean | last post by:
I cannot get any (hex) number in the "0x80"-"0x89" range (inclusive) to write properly to a file. Any number in this range magically transforms itself into "0x3F". For instance, debugging shows...
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.