I was faced with not correct counts the number of written cyrillic letters, propose use function mb_strlen, because strlen counts bytes instead letterss instead letters.

CommentFileSizeAuthor
#2 fix_strlen-2956193-2.patch889 bytesr.nabiullin

Comments

nabiyllin created an issue. See original summary.

r.nabiullin’s picture

StatusFileSize
new889 bytes
r.nabiullin’s picture

Issue summary: View changes

  • Jaypan committed 6ede1b0 on 8.x-1.x authored by nabiyllin
    Issue #2956193 by nabiyllin: Not correct counts the number of written...
jaypan’s picture

Status: Active » Fixed

Thanks for the patch. It's been applied.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

andypost’s picture

+++ b/src/Plugin/Field/FieldWidget/TextFieldCounterWidgetTrait.php
@@ -70,7 +70,7 @@ trait TextFieldCounterWidgetTrait
+		$value_length = mb_strlen($value) - $newline_count;

Why hardcoding mb* instead of using \Drupal\Component\Utility\Unicode::strlen()???

andypost’s picture

needs follow-up

andypost’s picture

jaypan’s picture

Why hardcoding mb* instead of using \Drupal\Component\Utility\Unicode::strlen()???

For the same reason lots of things are not done by people: Because I didn't know it existed.