Post by keyuri33 » Wed Jan 03, 2018 5:59 pm

I get special character issue

Try this code:

Code: Select all

{{ custom_block[lang]['description'] | convert_encoding('UTF-8', 'HTML-ENTITIES') }}
My text: ľščťžýáíé

Output: ľšÄťžýáíé

What is correct way?

Thanks


Newbie

Posts

Joined
Tue Aug 09, 2016 3:50 pm

Post by D3MO » Thu Jan 04, 2018 1:31 am

Is your database is set to UTF 8 ?:)

Opencart Expert | voldemaras@gmail.com
Skype - programanija | Gtalk - voldemaras@gmail.com
Extensions for Opencart @ https://www.opencartextensions.eu / or Opencart Marketplace

Need Custom Module? debug third party module or simply have any question related to Opencart? feel free to contact directly for a live chat session:) - INSTANT LIVE CHAT


User avatar
Active Member

Posts

Joined
Mon Apr 04, 2011 6:57 am

Post by keyuri33 » Thu Jan 04, 2018 2:34 pm

I have again specify in detail with my code. I have try following code for custom block. it is working fine when I does add content from admin. but, just issue for special character.

admin\view\template\extension\module\theme_module.twig

Code: Select all

<div class="tab-content">
                    {% for language in languages %}
                    <div id="tab8-language-{{ language.language_id }}" class="tab-pane">
                      <div class="form-group">
                        <div class="col-sm-10">
                        <textarea name="custom_block[{{ language.language_id }}][description]" data-toggle="summernote" data-lang="{{ summernote }}" class="form-control" id="input-description8{{ language.language_id }}">{{ custom_block[language.language_id].description ? custom_block[language.language_id].description }}</textarea>
                        </div>
                      </div>
                    </div>
                    {% endfor %}
                  </div>
admin\controller\extension\module\theme_module.php

Code: Select all

if (isset($this->request->post['custom_block'])) {
            $data['custom_block'] = $this->request->post['custom_block'];
        } else {
            $data['custom_block'] = $this->config->get('custom_block');
}
catalog\controller\common\header.php

Code: Select all

$data['config_language_id'] = $this->config->get('config_language_id');    
$data['custom_block'] = $this->config->get('custom_block');
catalog\view\theme\default\template\common\header.twig

Code: Select all

{% set lang = config_language_id %}    
{% if custom_block[lang]['description'] %}
       {{ custom_block[lang]['description'] | convert_encoding('UTF-8', 'HTML-ENTITIES') }}
    {% endif %}
when I does add content something like from admin: ľščťžýáíé

So, does Output: ľšÄťžýáíé

Thanks


Newbie

Posts

Joined
Tue Aug 09, 2016 3:50 pm

Post by straightlight » Thu Jan 04, 2018 7:08 pm

Caused by an installed extension. If downloaded from the marketplace, contact the extension developer to resolve this issue.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by keyuri33 » Fri Jan 05, 2018 2:57 pm

straightlight wrote:
Thu Jan 04, 2018 7:08 pm
Caused by an installed extension. If downloaded from the marketplace, contact the extension developer to resolve this issue.
Here, I have not use any third party extension. I have build my self module. and, it was working fine for older OpenCart version. but, this issue does create for latest opencart version 3.0.2.0.

I have use following code for older opencart version. it is working fine in older OpenCart version.

Code: Select all

<?php if($custom_block == 1) {
if(isset($custom_block[$lang]['description']) && $custom_block[$lang]['description']!=""){?>
<?php echo html_entity_decode($custom_block[$lang]['description'], ENT_QUOTES, 'UTF-8'); ?>
<?php } ?>
Following code is use for latest version 3.0.2.0. & it does create just issue for special character.

Code: Select all

{% if custom_block[lang]['description'] %}
{{ custom_block[lang]['description'] | convert_encoding('UTF-8', 'HTML-ENTITIES') }}
{% endif %}
<?php } ?>
What is wrong here? have you any solution for that?

Thanks


Newbie

Posts

Joined
Tue Aug 09, 2016 3:50 pm

Post by Axel Wers » Sat Jan 06, 2018 12:13 am

I can confirm this with custom template. In settings in template, when I put special characters to summernote editor, on front-and I see totally mess. OC 3.0.2.0. database utf8_unicode_ci

The same make chinese words, for example. In menu is original, in submenu the same which I put to summernote editor.

Attachments

chinese.png

chinese.png (2.59 KiB) Viewed 2107 times


OC 2.3.0.2


New member

Posts

Joined
Fri Aug 22, 2014 3:59 pm
Who is online

Users browsing this forum: No registered users and 509 guests