Japanese username?

Can user registered in Kanji?

Comments

  • Have you tried?

    What version of Vanilla are you running?

    From a cursory look at the GDN_User table in 2.0.18.8, it appears that the name field is set as 'utf8_unicode_ci' which should support Kanji.

  • I think they must change the code in the registration verification from ASCII to unicode.

    http://vanillaforums.org/discussion/23312/wrong-error-with-member-registration#latest

  • Good catch @vrijvlinder. What I meant to say is that the underlying software supports it. :D

    I would add a user manually (through phpmyadmin or the like) using a Kanji name and see if anything barks at you.

  • I am using 2.0.18.4 and not working for me
    I will try the latest ones

  • After update I still get this error while registrating with kanji

    Username can only contain letters, numbers, underscores, and must be between 3 and 20 characters long.

  • edited April 2013

    You would be better off changing this

    **in /library/core/functions.validation.php**
    
    try to find this
    
    '/^([\d\w_]{3,20})?$/si'
     
    and replace it with this or whatever is needed :
     
    '/^([\p{L}\p{N}\p{Pd}\p{Pc}\p{Lm}\p{M}]{3,20}+)?$/'
     
    in this function below
     
     Redefine ValidateUsername() function
     
    if (!function_exists('ValidateUsername')) {
       function ValidateUsername($Value, $Field = '') {
          if (preg_match('/(^[ ]|[ ]{2}|[ ]$)/', $Value)) return FALSE; // JDJ Fail on leading, trailing or runs of spaces
          return ValidateRegex(
             $Value,
             '/^([\d\w_ ]{3,40})?$/si' // JDJ Allow spaces and 40 char length
          );
       }
    }
     
     
     **Changing the Regex filter from ascii-only to Unicode,which will allow you to use any kind of letters from any language..**
     
    you can also customize your filter to allow or disallow specific characters by adding or removing Unicode components (the "p{x}" components within the Regex filter). Here is a small list of what each of those components mean:
     
    \p{L}: any kind of letter from any language.
    \p{Lm}: a special character that is used like a letter. 
    \p{M}: a character intended to be combined with another character (e.g. accents, umlauts, enclosing boxes, etc.).
    \p{N}: any kind of numeric character in any script. 
    \p{Z}: any kind of whitespace or invisible separator. 
    \p{Pd} or \p{Dash_Punctuation}: any kind of hyphen or dash. 
    \p{Pc}: a punctuation character such as an underscore that connects words. 
     
    for a complete list of Unicode components, refer to this url:
    
    http://www.regular-expressions.info/unicode.html
     
     
  • I have no way to test inputting Kanji characters, but this should theoretically work. Place the following in your /conf/config.php file.

    $Configuration['Garden']['User']['ValidationRegex'] =  '\p{L}';
    $Configuration['Garden']['User']['ValidationLength'] =  '{2,20}';
    
  • An aside: @vrijvlinder remember you can redefine all functions that have an include guard. In this case, you could place your modified ValidateUsername function in your /conf/bootstrap.before.php file to swap out the function for your modified one without hacking the core. :D

    To expand, you can do this for any function that is included right after an if(!function_exists('NameToOverride')) { block.

  • wow it works now @hgtonight
    thanks for the simple easy answers

  • @hgtonight said:
    An aside: vrijvlinder remember you can redefine all functions that have an include guard. In this case, you could place your modified ValidateUsername function in your /conf/bootstrap.before.php file to swap out the function for your modified one without hacking the core. :D

    Ah ! here is another idea for a plugin to avoid hacking the core no? I like the config solution, less hassle for sure.

  • @altious I never would have found it if not for @vrijvlinder's persistence into looking into it. :D

Sign In or Register to comment.