List Info

Thread: Trouble encoding characters




Trouble encoding characters
user name
2006-11-28 09:20:44

Let¡¯s give it another go. I hope I am now complete in supplying data to my problem;

 

I am using perl v.5.8.7 and use the library

¡°use XML::LibXML;¡±

 

When I add a text like ¡°test ¨¦¡± to the xml file I get a weird encoded xml file. At least, when it is read into Exact, an accounting program, it does not get accepted. When I open it in an text editor I see ¡°<Description>test ´¿Description>¡± where the utf-8 encoded string ¡°¨¦</¡± can¡¯t be read correctly.

 

In the code there is something that I don¡¯t really understand that might f*** it up.

 

The code:

 

Get the info from the db:

  my $orders_sql = '<some query>;

  my $sth = $db_handle->prepare($orders_sql);

  $sth->execute() || die $db_handle->errstr;

 

  if(my $r_orderinfo_hash=$sth->fetchrow_hashref()){

 

In the database the value is: ¡°test ¨¦¡± (I checked)

 

Now the adding to the XML part (the first row line might be the problem):

 

 $r_orderinfo_hash->{'ordr_comments'} =~ s/n/ /gis;

 my $description_node = XML::LibXML::Element->new( &quot;Description" );

 

Other solution I tried;

 

An ¡°&¡± gets encoded to ¡°&amp;¡± so I can¡¯t try to encode all characters by making ¡°&#...¡± character encoding strings, which results in ¡°&amp;#...¡±.

 

I see 2 ways out of this. 1 I try to encode the ¡°¨¦¡± correctly so it can be read, or I prevent the ¡°&¡± from being encoded into an ¡°&amp;¡±

 

 

Greetings,

 

Marijn Pessers

 

[1]

about | contact  Other archives ( Real Estate discussion Medical topics )