Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

How to Enable UTF-8 in Civil Tongue

XfronterXfronter New
edited October 2015 in Vanilla 2.0 - 2.8

How can i Add ** UTF-8 ** Words to Civil Tounge.
Please Guide me

Comments

  • Anyone Here Know This

  • peregrineperegrine MVP
    edited October 2015

    In both versions.

    I think there is a bug in both civil tongue ex in github and civil tongue

    if you snip out getpattern routine and try a simple example

    if ê is at the end of word replacement fails.

    if ê is in the middle of word replacement works..

    e.g.

    <?php
    $Words = "vanillaê;vanêlla";
    
    $Text = "I want to replace vanillaê and vanêlla";
    
    $ExplodedWords = explode(';', $Words);
    foreach($ExplodedWords as $Word) {              
                if (trim($Word))
                      $Patterns[] = '`\b' . preg_quote(trim($Word), '`') . '\b`is';  // civiltongueex
               //      $Patterns[] = '/\b' . preg_quote(ltrim(rtrim($Word))) . '\b/is'; // civiltongue
                }
    $Result = preg_replace($Patterns, "****", $Text);
    
    echo $Result;
    

    produces

    I want to replace vanillaê and ****

    you could look in code for $Patterns

    and try adding a "u" after the "s"

    $Patterns[] = '`\b' . preg_quote(trim($Word), '`') . '\b`isu';
    

    and it will correctly produce

    I want to replace **** and ****

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • peregrineperegrine MVP
    edited October 2015

    if you want to match censored word ชื่อที่คุณ

    with a thai word as an example (english would be slightly different).

    • option A

    with this comment

    XYZชื่อที่คุณXYZ and ชื่อที่คุณ

      $Patterns[] = '`\b' . preg_quote(trim($Word), '`') . '\b`is';
    

    censors matches if not first or last letter.

    XYZ****XYZ and ชื่อที่คุณ


    • option B

    text body
    XYZชื่อที่คุณXYZ and ชื่อที่คุณ

    $Patterns[] = '`\b' . preg_quote(trim($Word), '`') . '\b`isu';
    

    censors match only for exact word

    XYZชื่อที่คุณXYZ and ****


    • option C

    text body
    XYZชื่อที่คุณXYZ and ชื่อที่คุณ

    and doubling pattern array

    $Patterns[] = '`\b' . preg_quote(trim($Word), '`') . '\b`is';
    $Patterns[] = '`\b' . preg_quote(trim($Word), '`') . '\b`isu';
    

    censors match for part of word and word

    XYZ****XYZ and ****

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • Simply Awesome.. Working Fine ;)
    Thanks Lot B)

Sign In or Register to comment.