Export character problems

  • Posts: 171
  • Thank you received: 9
10 years 11 months ago #168930

-- HikaShop version -- : 2.3.2
-- HikaMarket version -- : 1.4.1

Hi,

I'm trying to export on frontend the orders and ordered products in export view (HikaMarket). I'm writing here, because I see HikaMarket uses HikaShop's helper for that. I also use on our site quickbook plugin , to be totally clear.

I had character problems with Hungarian language (á,é,í,ó,ő,ö,ü,ű,ú). When exported in CSV I had to import it as text, when I opened it automatically in Excel, the chars was confused as well in XLS.

For example:
SOS kiszállítás
Másik tűzjelző

So I tried to solve it myself by editing /administrator/com_hikashop/helpers/spreadsheet.php and it's almost perfect both in XLS and CSV. Now only 'ő' and 'ű' chars are converted to '?' all the other chars exported correctly.

In the file I added around line 85:

if( $this->format == 0 )
echo mb_convert_encoding($this->buffer, 'Windows-1252');
else {
echo $this->buffer;
}

And for Excel in function writeText:
$len = strlen(utf8_decode($value));
and
$this->buffer .= utf8_decode($value);

Now I get:
SOS kiszállítás
Másik t?zjelz?

I should get:
SOS kiszállítás
Másik tűzjelző

Can anybody help how to solve that?

Please Log in or Create an account to join the conversation.

  • Posts: 84219
  • Thank you received: 13670
  • MODERATOR
10 years 11 months ago #168999

Hi,

You should not need to change any code. HikaShop already exports your data in UTF8 which handles almost all the existing characters of almost all the existing languages on earth.
The issue is more during the import process in Excel where you need to choose UTF8 when you open the file so that it displays the characters properly.
What you're doing with your code is to convert the UTF8 data into Windows-1252 which is a format which supports only a handful of specific characters and thus, for the characters it doesn't support, it puts a question mark instead.

Please Log in or Create an account to join the conversation.

  • Posts: 171
  • Thank you received: 9
10 years 11 months ago #169274

nicolas wrote: Hi,

You should not need to change any code. HikaShop already exports your data in UTF8 which handles almost all the existing characters of almost all the existing languages on earth.
The issue is more during the import process in Excel where you need to choose UTF8 when you open the file so that it displays the characters properly.
What you're doing with your code is to convert the UTF8 data into Windows-1252 which is a format which supports only a handful of specific characters and thus, for the characters it doesn't support, it puts a question mark instead.


OK, it should work like that, but chars áéíóöőúüű and same capitals ÁÉÍÓÖŐÚÜŰ exported for me by default not correct in both Excel and CSV. In case CSV I can solve it by adding "Add data from file" in Excel, in that case it's OK (I dont't know why). We wanna avoid that, to force our accountants to click 3-4-5 times more to import it correctly in Excel.

That's why I tried to do that encode. I know UTF8 should be OK for me, but when I set
echo mb_convert_encoding($this->buffer, 'Windows-1252');
is because this just misses the ő and ű, but
echo mb_convert_encoding($this->buffer, 'utf8');
is misses more chars.

Would you mind if I ask you to also try to make a test with chars ű and ő on your server somehow?
I also checked demo server's admin (demo.hikashop.com), exported the orders, and for example Rhône has also a special charachter, and it's not displayed correctly for me either, if I open it in Excel.

Last edit: 10 years 11 months ago by pepecortez. Reason: spelling fail

Please Log in or Create an account to join the conversation.

  • Posts: 171
  • Thank you received: 9
10 years 11 months ago #169331

After hours of playing solved it this way, maybe someone has the same problem.

In file /administrator/com_hikashop/helpers/spreadsheet.php

In the file I added around line 85:

if( $this->format == 0 )
echo mb_convert_encoding($this->buffer, 'iso-8859-2', 'auto');
else {
echo $this->buffer;
}

And for Excel in function writeText:
$len = strlen(utf8_decode($value));
and
$this->buffer .= mb_convert_encoding($value, 'iso-8859-2', 'auto');

Last edit: 10 years 11 months ago by pepecortez.
The following user(s) said Thank You: Xavier

Please Log in or Create an account to join the conversation.

Time to create page: 0.060 seconds
Powered by Kunena Forum