Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6538511
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:44:40+00:00 2026-05-25T10:44:40+00:00

strlen($username); Username can carry ASCII, Unicode or both. Example: Jam123 (ASCII) – 6 characters

  • 0
strlen($username);

Username can carry ASCII, Unicode or both.

Example:

Jam123 (ASCII) – 6 characters
ابت (Unicode) – 3 characters but strlen returns 6 bytes as unicode is 2 bytes per char.
Jamت (Unicode and ASCII) – 5 characters (3 ASCII and 2 Unicode even though i have only one unicode character)

Username in all cases shouldn’t go beyond 25 characters and shouldn’t be less than 4 chars.

My main problem is when mixing Unicode and ASCII together, how can i keep track of count so the condition statement can deicde whether username is not over 25 and not less than 4.

if(strlen($username) <= 25 && !(strlen($username) < 4))

3 characters in unicode will be counted as 6 bytes which causes trouble because it allows user to have a username of 3 unicode characters when the characters should be minimum of 4.

Numbers will always be in ASCII

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T10:44:40+00:00Added an answer on May 25, 2026 at 10:44 am

    Use mb_strlen(). It takes care of unicode characters.

    Example:

    mb_strlen("Jamت", "UTF-8"); // 4
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

if (strlen($title) && strlen($message) > 3) This returns true if $title is over 3
I tried: mb_strlen('普通话'); strlen('普通话'); both of them output 9,while in fact there are only
I have this script through which I can change my LDAP password but I
The username row comes out perfectly but the password row refuses to come through.
I am trying to append random numbers to different numbers of characters. Can anyone
if (strlen($comment > 2)) { Ok, so I only want to exec this if
int length = strlen(src); char *structSpace = malloc(sizeof(String) + length + 1); String *string
What is the Perl equivalent of strlen() ?
I have a simple C function which I declare as: int strLen(const char* str_)
I've read that it is bad practice to call strlen() in my for loop

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.