Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID Sign In with Twitter

Categories

In this Discussion

  • A044 December 2011
  • x00 December 2011

Who's Online 16

CurtisOdenRicardo_Viteriericgillettefh111tc74 +11 guests

[Solved] Cyrillic characters in spoiler tag

This discussion is related to the Spoilers addon.

All is fine when I use Latin characters:
[spoiler=test]test[/spoiler]
But the spoiler is not displayed correctly when I use the Cyrillic characters:
[spoiler=тест]test[/spoiler]

How can I fix it? I use Vanilla 2.0.18.1. Thanks in advance you for answers.

Tagged:

Comments

  • Posts: 15

    Found the answer. It is necessary to change the line 57:
    $Data->Body = preg_replace_callback("/(\[spoiler(?:=\"?([\d\w_',.? ]+)\"?)?\])/", array($this, 'SpoilerCallback'), $Data->Body);
    to:
    $Data->Body = preg_replace_callback("/(\[spoiler(?:=\"?([\d\w_абвгдеёжзийклмнопрстуфхцчшщъыьэюяАБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ«»',.? ]+)\"?)?\])/", array($this, 'SpoilerCallback'), $Data->Body);

    I would be grateful if someone will confirm or disprove the correctness of this decision.

  • x00x00
    Posts: 1,548

    use [\d\p{L}_',\.\?]+

    that will match any kind of letter in any language.

    [\d\w\p{Cyrillic}_',\.\?]+

    for Cyrillic and standard Latin

    grep is your friend.

  • Posts: 15

    Sorry, x00, but it doesn't work. Does p{L} and p{Cyrillic} ranges include " character? It may be a cause of problem, I guess.

  • x00x00
    Posts: 1,548 Accepted Answer 1 like

    I think you need the u modifier so

    $Data->Body = preg_replace_callback("/(\[spoiler(?:=\"?([\d\p{L}_',\.\?]+)\"?)?\])/ui", array($this, 'SpoilerCallback'), $Data->Body);

    the i modifier makes it case insensitive.

    grep is your friend.

  • x00x00
    Posts: 1,548

    you could try а-яА-Я

    grep is your friend.

  • x00x00
    Posts: 1,548

    the prior example is dependent on you version of php and PCRE

    grep is your friend.

  • Posts: 15

    It works with string:
    $Data->Body = preg_replace_callback("/(\[spoiler(?:=\"?([\d\p{L}_\-—«»',.?! ]+)\"?)?\])/ui", array($this, 'SpoilerCallback'), $Data->Body);

    Thank you for your help, x00.

  • x00x00
    Posts: 1,548

    No worries my friend.

    grep is your friend.

Sign In or Register to comment.