473,398 Members | 2,088 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,398 software developers and data experts.

Encode German characters in XML

69
Hi,

I'm doing some work for a German website. They want to be able to type in characters for which there are HTML entities like
Expand|Select|Wrap|Line Numbers
  1. Ü ü ä
. The plain text should be stored in a database so it can be later retrieved and read into an XML file. The XML file is read by a Flash file to create a news ticker.

Unfortunately the ticker is displaying some characters incorrectly. I thought that you would need to use html_entities when writing to the database, html_entity_decode when reading from it and the ISO encoding in the XML file. Could anyone tell me where I'm going wrong.

Expand|Select|Wrap|Line Numbers
  1.  
  2. // Writing to the database.
  3.  
  4. $sql = "UPDATE news SET title = " . '"' . htmlentities( addslashes($_POST['title']), ENT_QUOTES, 'ISO-8859-1' ) . '"' . ", article = " . '"' . 
  5.         addslashes($_POST['article']) . '"' . ", summary = " . '"' . addslashes($_POST['summary']) . '"';
  6.     if(isset($filename1)) $sql .= ", image_file = '$filename1' ";
  7.     $sql .= "WHERE news_id = {$_POST['articleId']}";
  8.  
  9. // Reading from the database.
  10. $sql = "SELECT * FROM news ORDER BY news_id DESC";
  11.     $result = $con->sqlExecute($sql);
  12.  
  13.     $xmlContent = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n";
  14.     $xmlContent .= "<ticker>\n";
  15.  
  16.     while($row=mysql_fetch_array($result, MYSQL_ASSOC)){
  17.         $xmlContent .= "<topic>\n";
  18.         $xmlContent .= "<text><![CDATA[<font size=\"12px\" color=\"#624A9E\"><b>" . html_entity_decode( $row['title'], ENT_QUOTES, 'ISO-8859-1' ) . "</b></font><br /><font size=\"12px\" color=\"#686868\">$row['summary'] )...</font><br /><font size=\"12px\" color=\"#624A9E\"><b>Read more</b></font>]]></text>\n";
  19.         $xmlContent .= "<link>NewsDetail.php?news_id={$row['news_id']}</link>\n";
  20.         $xmlContent .= "<targetIsUrl>Y</targetIsUrl>\n";
  21.         $xmlContent .= "</topic>";
  22.     }
  23.  
  24. // First line of XML.
  25. <?xml version="1.0" encoding="ISO-8859-1"?>
  26.  
  27.  
Thanks,

Sean
Feb 14 '08 #1
1 4382
MarkoKlacar
296 Expert 100+
Hi Sean,

I've done a simliar thing but with swedish characters, ÅÄÖåäö, I did not do any of the things you are talking about and it worked out fine, the PHP bit.

Maybe the flash is doing something nasty to the characters.
Feb 15 '08 #2

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

Similar topics

1
by: Jeff | last post by:
Having a problem displaying both german and chinese characters from a UTF-8 database on the same *.jsp page. Can make Chinese characters appear correctly by including the following lines: <%@...
5
by: Scott Matthews | last post by:
I've recently come upon an odd Javascript (and/or browser) behavior, and after hunting around the Web I still can't seem to find an answer. Specifically, I have noticed that the Javascript...
4
by: Newbie | last post by:
How would I modify this form to encode *all* the characters in the 'source' textarea to the '%xx' format & place result code into the 'output' textarea? (cross browser compatable) Any help is...
4
by: Darrel | last post by:
How does HTML.encode work? I'm trying to save text in a hidden form field into a SQL DB. The tedt is HTML (from a WYSIWYG editor...X-standard). One problem I have is that stray apostrophe's in...
0
by: Markus Wollny | last post by:
Hi! Sorry to bother you, but I just don't know how to get tsearch2 configured correctly for my setup. I've got a 7.4.3 database-cluster initdb'ed with de_DE@euro as locale, the database is with...
5
by: Timothy Madden | last post by:
Hello Is there a function that will allow me to output text written in utf-8 (from db for example) if my document has Content-Type: text/html; charset=ISO-8859-1 I mean htmlspecialchars()...
6
by: 7stud | last post by:
s1 = "hello" s2 = s1.encode("utf-8") s1 = "an accented 'e': \xc3\xa9" s2 = s1.encode("utf-8") The last line produces the error: --- Traceback (most recent call last):
1
by: anonymous | last post by:
1 Objective to write little programs to help me learn German. See code after numbered comments. //Thanks in advance for any direction or suggestions. tk 2 Want keyboard answer input, for...
0
by: rajana | last post by:
Dear All, We have Ansi file with german characters (Ä / Ø) , We are using Streamreader to read the contents of the file. But Readline() not able to read the German characters. We tried all...
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
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.