SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Hybrid View

  1. #1
    SitePoint Addict tlacaelelrl's Avatar
    Join Date
    Apr 2011
    Location
    Mexico city, Mexico
    Posts
    353
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Post Russian characters

    I have a small script which works just fine it displays a calendar, however someone downloaded it and wants to use it in Russian, here is a link to a demo site the calendar is on the left, if you notice the calendar is displayed just fine at first, however if you skip a month or a year then on update the calendar will display unknown symbols, is there something special that needs to be done to the file in order for it to work?

    The problem is that the day initials are sent on post

    The calendar works fine if language is set to English.

    Edit: just wanted to add that the day initials are stored in a JavaScript variable
    var dayInitials99 = "ПВСЧПСВ"
    Do you get bothered because I do the same thing every day?
    Do you question why I do it?
    Then find something that you actually like doing!!!

    Stop thinking on what I do.

  2. #2
    SitePoint Addict tlacaelelrl's Avatar
    Join Date
    Apr 2011
    Location
    Mexico city, Mexico
    Posts
    353
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    What I did to fix this was replace dayInitials99 = "ПВСЧПСВ" for dayInitials99 = "П|В|С|Ч|П|С|В" and use explode instead of str_split
    Do you get bothered because I do the same thing every day?
    Do you question why I do it?
    Then find something that you actually like doing!!!

    Stop thinking on what I do.

  3. #3
    SitePoint Wizard TheRedDevil's Avatar
    Join Date
    Sep 2004
    Location
    Norway
    Posts
    1,198
    Mentioned
    4 Post(s)
    Tagged
    1 Thread(s)
    The reason you had issues is due to str_split is not multibyte safe.

    In short, this means that it can potentially split multibyte characters "in the middle" i.e. after 7 bit instead after 16 bit.

    When working with multibyte languages make certain you use the mb_ string functions, or enable it in the php.ini file so it automatically use it when available.

    In your case, you would need to use mb_split, though its slightly different since this one is based on a regex, so you would need to tell it where to split.

  4. #4
    SitePoint Addict tlacaelelrl's Avatar
    Join Date
    Apr 2011
    Location
    Mexico city, Mexico
    Posts
    353
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by TheRedDevil View Post
    The reason you had issues is due to str_split is not multibyte safe.

    In short, this means that it can potentially split multibyte characters "in the middle" i.e. after 7 bit instead after 16 bit.

    When working with multibyte languages make certain you use the mb_ string functions, or enable it in the php.ini file so it automatically use it when available.

    In your case, you would need to use mb_split, though its slightly different since this one is based on a regex, so you would need to tell it where to split.
    Thank you, I have just learned that the string functions I was using would not work for some languages and since I am trying to target that public I will be more careful in the future
    Do you get bothered because I do the same thing every day?
    Do you question why I do it?
    Then find something that you actually like doing!!!

    Stop thinking on what I do.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •