473,387 Members | 1,791 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,387 software developers and data experts.

Cannot change encoding at a XML with php

mikek12004
200 100+
I have an xml written in a file. I want in the 1st line
<code>
<?xml version="1.0" encoding="iso-88-59-7"?>
</code>
to change the encoding to utf-8 any easy way to do that?
Nov 11 '08 #1
5 3051
Dormilich
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)

regards
Nov 11 '08 #2
mikek12004
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"/>
  5.  
  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>
  17.  
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'];
  2.  
  3.     $file = fopen("../player/".$id.".xml","r");
  4.     $msg=fread($file,filesize("../player/".$id.".xml"));
  5.     fclose($file);
  6.  
  7.     //$msg=str_replace("iso-8859-7","utf-8",$msg);
  8.     $file = fopen("../player/".$id.".xml","w");
  9.     fwrite($file,$msg);
  10.     fclose($file);
  11.  
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
Dormilich
8,658 Expert Mod 8TB
I think you have to actually encode the content to utf-8. use utf8_encode().

regards
Nov 11 '08 #4
mikek12004
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
Dormilich
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

2
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...
8
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 -------------------------------------------------------------------------------- ...
1
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...
1
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...
1
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: -...
4
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....
3
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...
3
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...
4
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
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...
0
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...
0
marktang
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,...
0
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...
0
jinu1996
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 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.