HTML Logo by World Wide Web Consortium (www.w3.org). Click to learn more about our commitment to accessibility and standards.

Moving forward with Composr

ocPortal has been relaunched as Composr CMS, which is now in beta. ocPortal 9 will be superseded by Composr 10.

Head over to compo.sr for our new site, and to our migration roadmap. Existing ocPortal member accounts have been mirrored.


Lost characters in expandable menu

Login / Search

 [ Join | More ]
 Add topic 
Posted
Rating:
#28758 (In Topic #6601)
Avatar

Community saint

I created a gallery, which name contains specific Lithuanian characters.
But when I tried to upload pictures in there I found its name with lost characters.
I use UTF-8 encoding, which is ok everywhere on the portal. I have read the topic that php doesn fully support utf-8. Could it be the case?



But in site-tree view its name is shown correctly (see the bottom line):

Back to the top
 
Posted
Rating:
#28858
Avatar

I'm really really pleased UTF8 is almost working, because I didn't think it would. I believe your problem can be corrected by changing lines 1408-1420 of sources/support.php from:

Code

function xmlentities($string,$quote_style=ENT_COMPAT)
{
   //removed-assert

   $trans=get_html_translation_table(HTML_ENTITIES,$quote_style);

   foreach (array_keys($trans) as $key)
   {
      $trans[$key]='&#'.strval(ord($key)).';';
   }

   return str_replace('?','?',strtr($string,$trans));
}
to just:

Code

function xmlentities($string,$quote_style=ENT_COMPAT)
{
   return escape_html($string);
}


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Rating:
#28859
Avatar

PHP does not support unicode, unless non-default extensions are enabled and the web application specifically uses those extensions. ocPortal doesn't support that, and won't be doing so. When PHP version 6 comes out, PHP will properly support Unicode, and ocPortal will too.

However! Things seem to be working well for you, so it doesn't really matter if technically unicode is supported or not, if it appears to basically work. I've now given this some more thought, considering where the code might slip up due to the unicode not being properly processed.

Here are the areas:
  • When GD writes out text. This will be changed in the next patch release so that it works.
  • Any of the following text operations won't work perfectly in all situations: strtolower, strtoupper, ucfirst, ucwords, strpos, strlen, {}/substr. It's unavoidable that these might not work right, because PHP simply doesn't understand the unicode normally. So for example, the length of a unicode string would appear longer to PHP than it actually is if it contained rarer characters in it.

So, technically, things aren't going to be perfect. But I'll make sure that everything works that can work, and I'll make sure we're ready for PHP6 when it comes out.

It's worth pointing out that you should make sure that mySQL character set is set to 'utf8_lithuanian_ci'. It defaults to 'latin1_swedish_ci', which would not cause data loss for any ASCII character set – but for unicode, it might.


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
1 guests and 0 members have just viewed this: None
Control functions:

Quick reply   Contract

Your name:
Your message: