*

megacheb

  • *
  • 21 posts
Some problem with character encoding
« on: May 27, 2019, 12:01:39 PM »
Hello. I have some problem with encoding with first select - see pictures http://prntscr.com/ntukqo    http://prntscr.com/ntuog6
Problem someweare in string
Code: [Select]
$html .= '<option value="">' . ($name <> '' ? sprintf(__('[b]Select %s ...[/b]', 'attributes'), strtolower($name)) : __('Select value ...', 'attributes')) . '</option>';
Variable %s return wrong encoding. All other function work property with cyrillic.

Database and php has coding UTF-8

Any idea?

*

MB Themes

Re: Some problem with character encoding
« Reply #1 on: May 27, 2019, 12:07:31 PM »
@megacheb
Replace
Code: [Select]
sprintf(__('[b]Select %s ...[/b]', 'attributes'), strtolower($name))
with
Code: [Select]
__('Select', 'attributes') . ' ' . strtolower($name)
I do not think those attributes are original in plugin and yet never heard about such issue.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

megacheb

  • *
  • 21 posts
Re: Some problem with character encoding
« Reply #2 on: May 27, 2019, 12:18:20 PM »
Thanks for you reply. Original:  sprintf(__('Select %s ...', 'attributes') without
Code: [Select]
[b][/b]When i use without %s i have lost attribute name in first select.
http://prntscr.com/ntuw9x
« Last Edit: May 27, 2019, 12:34:13 PM by megacheb »

*

MB Themes

Re: Some problem with character encoding
« Reply #3 on: May 27, 2019, 01:01:15 PM »
Read precisely.

@megacheb
Replace
Code: [Select]
sprintf(__('[b]Select %s ...[/b]', 'attributes'), strtolower($name))
with
Code: [Select]
__('Select', 'attributes') . ' ' . strtolower($name)
I do not think those attributes are original in plugin and yet never heard about such issue.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

megacheb

  • *
  • 21 posts
Re: Some problem with character encoding
« Reply #4 on: May 27, 2019, 01:33:43 PM »
I found solution:
strtolower() does not work for for cyrillic chars. Proof: https://php.net/manual/en/function.strtolower.php

For cyrillic is necessary use mb_strtolower() or mb_convert_case

You, as a developer must know this and use universal solution, which work with various encoding!

Regards