1
brutalicuss
Problem with CYR character when setting value

Hi there!

Ive a "little" problem with some special cyrillic characters at the end of my "setting value" in few modules like "weblinks", "news" and others.
This characters shows like "?" only at the end of "setting" title or description in many blocks of these modules.
look here example: http://postimage.org/image/6xamfcczb/
All my pages are converted in UTF-8, there is no problem with encoding.
It happens only when "setting value" (for exp. 80 character in title and 200 in desc) falls in the word and convert the last (80th, 200th) in this strange "?"
I tried many many ways to fix this, but without success.

I'll very thankful if someone help me with this!

10x

2
irmtfan
Re: Problem with CYR character when setting value
  • 2012/6/10 7:28

  • irmtfan

  • Module Developer

  • Posts: 3419

  • Since: 2003/12/7


sorry i can not see the screenshot of your issue.
but i just guess that you have problem with 2-byte characters.

i think your cyrillic character need 2 bytes and with just 1 byte left in the field you have an strange ? instead.

For example when you have 80 characters in maximum and you typed 79 latin characters (1 byte language) then you CAN NOT add a 2-byte character like this cyrillic character Ѳ http://en.wikipedia.org/wiki/%D1%B2

because it has 2 bytes and it will be 81 characters in total and will exceed the maximum allowed and you have the ? in return.

Hope i could explain you the root of your problem.

3
brutalicuss
Re: Problem with CYR character when setting value

10x very much man, thats right, this is the real problem in "2-byte characters"

After many hours reading in the net I found decision for Ohwada's WEBLINKS.
I tried many "tricks" with strlen and substr but without success.
Finally fix it (for all they have same problem)
Its sumple:
module/happy_linux - folders "class" and "include"
add this funk at the beginning of files: strings.php (in class) and multibyte.php (in include)
<?php
mb_internal_encoding("UTF-8");
?>
Thats all!
This fix any "?" END characters in any block or title or description

Now looking for decision for module "catads", still have trouble with it

10x

4
brutalicuss
Re: Problem with CYR character when setting value

Foud for module "catads" (latest ads)
Was easier (after first) :)

modules/catads/blocks - file: catads_new.php
replace this line:
$a_item['title'] = substr($a_item['title'],0, $options[4] - $length1)."...";
with this:
$a_item['title'] = mb_substr($a_item['title'],0, $options[4] - $length1)."...";

the difference is only "mb_substr" instead "substr"
this call "Multibyte String" - almost all hosting company support this library

These were my xoops-problems for now :)

I like xoops really!

5
irmtfan
Re: Problem with CYR character when setting value
  • 2012/6/10 11:51

  • irmtfan

  • Module Developer

  • Posts: 3419

  • Since: 2003/12/7


you dont need to hard code mb_substr.
just use XoopsLocalAbstract::substr() instead of substr()

xoops core and module developers should use xoops local functions.
If developers didnt use these functions What is the usage of xoopslocal.php file and XoopsLocalAbstract class?


6
brutalicuss
Re: Problem with CYR character when setting value

Yes, you'r right! This is the easier way! I understand right now.
I have 6 xoops sites, but for first time looked in xoopslocal... "the man learns while living"
I spent much time... this will be lesson for me
10x for opening my eyes :)

Login

Username:
Password:

Lost Password? Register now!

Who's Online

62 user(s) are online (34 user(s) are browsing Support Forums)


Members: 0


Guests: 62


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Dec 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits