Osclass Support Forums

Osclass plugin support => Attributes Plugins => Topic started by: megacheb on May 27, 2019, 12:01:39 PM

Title: Some problem with character encoding
Post by: megacheb 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?
Title: Re: Some problem with character encoding
Post by: MB Themes 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.
Title: Re: Some problem with character encoding
Post by: megacheb 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
Title: Re: Some problem with character encoding
Post by: MB Themes 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.
Title: Re: Some problem with character encoding
Post by: megacheb 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