#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    5
    Rep Power
    0

    Unhappy PHP on WinXP seems to know how to set Russian locale only using CP1251 coding?


    Hello,

    PHP Code:
    print_r(setlocale(LC_ALL'russian')); 
    prints 'CP1251'
    and function strftime generates correct Russian months and weeks only in that coding...

    I would prefer it in UTF-8 though...

    Or what I am doing wrong?

    Also, may somebody from Russia advice on most popular coding there?

    Thanks,
    Grisha
  2. #2
  3. Did you steal it?
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,007
    Rep Power
    9398
    UTF-8 is a text encoding, not a locale. I think you'd have to use something like "russian.utf8" to get both.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    5
    Rep Power
    0
    Originally Posted by requinix
    UTF-8 is a text encoding, not a locale. I think you'd have to use something like "russian.utf8" to get both.
    requinix,
    that's right utf8 is encoding and strftime has to print russian names of weekdays and months in russian using what encoding?
    I tryed 'ru_RU.UTF8' without success...
    Code:
    setlocale(LC_ALL, 'russian','utf8');
    still returns in CP1251 encoded results
  6. #4
  7. Did you steal it?
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,007
    Rep Power
    9398
    "russian.utf8". Just one argument. Subsequent arguments are fallback values in case previous values don't work.
    PHP Code:
    setlocale(LC_ALL'russian.utf8''ru_RU.utf8'); 
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    5
    Rep Power
    0
    Originally Posted by requinix
    "russian.utf8". Just one argument. Subsequent arguments are fallback values in case previous values don't work.
    PHP Code:
    setlocale(LC_ALL'russian.utf8''ru_RU.utf8'); 
    This:
    Code:
    var_dump(setlocale(LC_ALL,'russian.utf8'));
    prints
    Code:
    boolean false
    and months appear in English farther down the running code
  10. #6
  11. Did you steal it?
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,007
    Rep Power
    9398
    A bit of quick research suggests you can't use UTF-8.
    MSDN: setlocale
    The set of available languages, country/region codes, and code pages includes all those supported by the Win32 NLS API except code pages that require more than two bytes per character, such as UTF-7 and UTF-8. If you provide a code page like UTF-7 or UTF-8, setlocale will fail, returning NULL.
    [edit] And I'm seeing that confirmed in a number of places. Use iconv() or mbstring to convert from a single-byte encoding (pick any you want) to UTF-8.
    Last edited by requinix; October 30th, 2012 at 02:37 PM.
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    5
    Rep Power
    0
    Originally Posted by requinix
    Fire up SSH or a console and run
    Code:
    locale -a
    What locale options does it show you? Those are what's available.
    There is no such command in Windows XP,
    but I have also Cygwin and in its terminal result seems good :

    ru_RU
    ru_RU.utf8
    russian

    How I can use this?

    Probably, my program will good when I transfer it to the hosting server which is on Linux system.
    Not very convenient though for debugging.
  14. #8
  15. Did you steal it?
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,007
    Rep Power
    9398
    You saw my post before I remembered you were on Windows. Read again.
  16. #9
  17. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    5
    Rep Power
    0
    Originally Posted by requinix
    [edit] And I'm seeing that confirmed in a number of places. Use iconv() or mbstring to convert from a single-byte encoding (pick any you want) to UTF-8.
    requinix,

    It looks like a possibility, but kind of weird... Isn't it?
    How Russian programmers live with it?
    They should have simpler solution, I guess...

IMN logo majestic logo threadwatch logo seochat tools logo