473,657 Members | 2,490 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Encode German characters in XML

69 New Member
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_dec ode 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 4404
MarkoKlacar
296 Recognized Expert Contributor
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
4753
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: <%@ page pageEncoding="UTF-8" %> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5
4099
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 encode() function behaves differently if a codepage has been set. For example: <script> document.write(escape('Ôèëìè')); (note: that should be five accented characters)
4
4894
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 appreciated. Regards.
4
7567
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 the HTML text are throwing a SQL error. Html.encode doesn't seem to do anything with these, eh? Secondly, does HTMLencode also encode already encoded items?
0
2096
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 Unicode encoding. I made and installed contrib/tsearch2 after installing the dump/reload-patch http://www.sai.msu.su/~megera/postgres/gist/tsearch/V2/regprocedure_7.4.patch.gz as advised by the docs. So far everything is looking good, I have...
5
4886
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() and htmlentities() will only convert characters that have an associated entity defined in HTML.
6
2329
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
5770
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 example: answer_str = raw_input(' Enter answer ') Herr Üü
0
2348
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 possibilities of calling the streamreader, but nothing worked. Dim sr As StreamReader = New StreamReader(Filename, System.Text.Encoding.Default, True) Dim sr As StreamReader = New StreamReader(Filename, _System.Text.Encoding.ASCII, False, 512)
0
8385
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8303
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8821
Oralloy
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8723
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8502
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8602
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7316
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4150
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.