News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Please do not use: utf8_encode(utf8_decode($text))

Started by Replika, April 16, 2008, 07:53:54 AM

Previous topic - Next topic

Replika

Since I can not access to dev.virtuemart.net, so I post here

My language charset is utf-8 and in the function safe_utf8_encode (which used in vmMail):
if( strtolower($charset) == 'utf-8') {
// safely decode and reencode the string
$text = utf8_encode(utf8_decode($text));
}

it damages the email subject.
example: "Sản phẩm được yêu cầu"
will be "S?n ph?m ???c yêu c?u"

Developers, please have a look.
Regards
--
Replika

Soeren

Could you please try this modification of the safe_utf8_encode function ?

if( strtolower($charset) == 'utf-8' &&  !seems_utf8( $text )) {
// safely decode and reencode the string
$text = utf8_encode($text);
}


Does this work?
The future of eCommerce: VirtueMart & Joomla!
http://virtuemart.net

korb

hi soeren
where goes this code? Does it solve the problem with PDF creation also?

Replika

#3
@Soeren
After checking, the code should be: ;)
if( strtolower($charset) == 'utf-8' && !vmAbstractLanguage::seems_utf8($text) ) {
// safely decode and reencode the string
$text = utf8_encode(utf8_decode($text));
}


edit:
I've had problem with utf8 in PDF also. Posted the feature request that using PDF creation in Joomla lib: http://dev.virtuemart.net/cb/issue/1584?navigation=true

korb

hi replika,
this code provided actaly works? where do you place it?

Replika

Quote from: korb on April 25, 2008, 01:06:55 AM
hi replika,
this code provided actaly works? where do you place it?
File: administrator/com_virtuemart/classes/language.class.php
Line: 150
But it's not for PDF issue

greyow

Hi Soeren,

I think this encode is not needed.

For the most accentuated languages the ISO-8859-1 is not enough,
so the language file isn't possible to be written in ISO-8859-1.
The utf8_encode of php encodes an ISO-8859-1 string to UTF-8.

Interpreters know in what way to save the file, I think you should delete this part.

You can try it.