Pages (2): 1 2   
Member
Member
adas   13-01-2006, 22:45
#1

I install a Zenphoto on my server. And I saw that in themes don't have a encoding declaration:
` (my server send all pages inISO-8859-2`). Polish chars are broken.

And I saw that Ajax script to add a titles and description save a polish chars (?, ?, ?, ?, ?, ó, ?, ?...) bad.
Example:

Quote:?a?ó?? ?ó?t? ja??
changing to:

Quote:Za%u017Có%u0142%u0107 %u017Có%u0142t%u0105 ja%u017A%u0144

Member
Member
pronvit   14-01-2006, 00:45
#2

i've sent patches to fix this to tristan some time ago but still no reply..

Member
Member
adas   19-01-2006, 19:36
#3

pronvit: write it in comment.

Member
Member
pronvit   19-01-2006, 21:13
#4

add to beginning of template-functions.php
`

/**

  • Function converts an Javascript escaped string back into a string with specified charset (default is UTF-8).

  • Modified function from http://pure-essence.net/stuff/code/utf8RawUrlDecode.phps

  • @param string $source escaped with Javascript's escape() function

  • @param string $iconv_to destination character set will be used as second paramether in the iconv function. Default is UTF-8.

  • @return string

*/

function unescape($source, $iconv_to = 'UTF-8') {

$decodedStr = '';

$pos = 0;

$len = strlen ($source);

while (&#36;pos < &#36;len) {

   &#36;charAt = substr (&#36;source, &#36;pos, 1);

   if (&#36;charAt == '%') {

       &#36;pos++;

       &#36;charAt = substr (&#36;source, &#36;pos, 1);

       if (&#36;charAt == 'u') {

           // we got a unicode character

           &#36;pos++;

           &#36;unicodeHexVal = substr (&#36;source, &#36;pos, 4);

           &#36;unicode = hexdec (&#36;unicodeHexVal);

           &#36;decodedStr .= code2utf(&#36;unicode);

           &#36;pos += 4;

       }

       else {

           // we have an escaped ascii character

           &#36;hexVal = substr (&#36;source, &#36;pos, 2);

           &#36;decodedStr .= chr (hexdec (&#36;hexVal));

           &#36;pos += 2;

       }

   }

   else {

       &#36;decodedStr .= &#36;charAt;

       &#36;pos++;

   }

}

if (&#36;iconv_to != "UTF-8") {

   &#36;decodedStr = iconv("UTF-8", &#36;iconv_to, &#36;decodedStr);

}

return &#36;decodedStr;

}

/**

*/

function code2utf(&#36;num){

if(&#36;num6)+192).chr((&#36;num&63)+128);

if(&#36;num>12)+224).chr(((&#36;num>>6)&63)+128).chr((&#36;num&63)+128);

if(&#36;num>18)+240).chr(((&#36;num>>12)&63)+128).chr(((&#36;num>>6)&63)+128) .chr((&#36;num&63)+128);

return '';

}

`

then change stripslashes(&#36;newtitle) to stripslashes(unescape(&#36;newtitle))
and stripslashes(&#36;newdesc) to stripslashes(unescape(&#36;newdesc)).

and don't forget to add meta content-type = utf-8

Member
Member
adas   20-01-2006, 17:39
#5

Thanks. But one polish letter (ó) doesn't work now fine.

Developer
Developer
trisweb   22-01-2006, 00:02
#6

I'm sure there are better ways to do this. I have pronvit's mods, but I'll look into better encoding options.

Thanks for the report.

Member
Member
pronvit   22-01-2006, 11:50
#7

why this way isn't good enough?

Developer
Developer
trisweb   22-01-2006, 23:42
#8

It might be, I just always look for the best way... is there something wrong with that? ;-)

It probably is fine. You're welcome to hack ZP to use it if need be.

Member
Member
pronvit   25-01-2006, 22:40
#9

nothing wrong.
but I think that these encoding problems are quite critical for non-english users. and why to search for something more if solution is available

Member
Member
adas   26-01-2006, 17:46
#10

Quote:encoding problems are quite critical for non-english users
It's a very big problem.

Member
Member
WeiChen   31-01-2006, 00:56
#11

Easy solution for non-english users.

add
header("Content-type: text/html; charset=utf-8");
into zp/index.php in the first line to override the default charset.
in Sajax.php, replace "escape" with "encodeURIComponent".
It works very well for Chinese characters.
http://blog.dukechina.org/gallery/

Member
Member
adas   31-01-2006, 09:32
#12

WeiChen: thanks

Member
Member
adas   31-01-2006, 09:37
#13

I think, that this line:
header("Content-type: text/html; charset=utf-8");
is good thing to adding into admin.php

Junior Member
Junior Member
spacemonkey   21-02-2006, 21:33
#14

Shouldn't a simple htmlentities() PHP function change any special character to a valid html entity? I mean it converts all applicable characters to HTML entities. http://fi.php.net/htmlentities . I just don't know where to put this so that it would convert the text to html entities BEFORE it's saved to the database. I need Finnish/Scandinavian characters and they're coming out as just blocks or question marks. Help, please. Where could I put this?

Member
Member
hdort   08-03-2006, 22:37
#15

WeiChen: seems to work ok for German, too! Many thanks!

Perhaps this change should be added in the next version?

Unregistered
Unregistered
Guest   20-04-2006, 20:48
#16

Oh, but this doesn't work for Russian language... shit =)

Member
Member
Mania   21-04-2006, 06:40
#17

Spacemonkey: I used WeiChen method but with a charset ISO-8859-15 to make Finnish letters work.

However, if the image has Finnish letters, it won't display properly.

Member
Member
adas   31-05-2006, 09:40
#18

In latest version this bug is not resolved...

Developer
Developer
trisweb   31-05-2006, 20:23
#19

It is now! Version to be released today with support for any desired character-set, including UTF-8 by default.

Member
Member
JohnieRoger   02-12-2007, 06:30
#20

It still shows all scandinavian letters (ä,å,ö) as question marks in File Info and Tags. Does anyone know what to do for this?

Pages (2): 1 2   
  
Powered By MyBB, © 2002-2026 MyBB Group.
Made with by Curves UI.