Get the Chinese Char to be displayed correctly

  • Posts: 107
  • Thank you received: 1
11 years 10 months ago #83593

Hi there,

This is the code which I used to get the chinese name of the customer:

$vars["name"]=@$order->cart->$address_type->address_firstname;

echo $vars["name"];

However, the word is garbled.

How can I fix this problem?

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

  • Posts: 82817
  • Thank you received: 13360
  • MODERATOR
11 years 10 months ago #83919

Hi,

Where are you trying to do that ?
Could you give a link ?
It's probably an issue of page encoding and it doesn't require that you change that code.

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

  • Posts: 107
  • Thank you received: 1
11 years 10 months ago #83932

Dear,

I tested this because I have to link to EZSHIP shipping page. EZSHIP offers an API, and I have to pass the required parameters to EZSHIP.

I wrote the code as follows:

<?php
defined('_JEXEC') or die('Restricted access');
header('Content-Type: text/html; charset=UTF-8');
?>

<?php
	       
	
	
	
		$user = hikashop_loadUser(true);
		$address_type = 'billing_address'; // or 'billing_address'
		$app =& JFactory::getApplication();
		$address = $app->getUserState( HIKASHOP_COMPONENT.'.'.$address_type);
		$cart = hikashop_get('class.cart');
		$cart->loadAddress($order->cart, $address, 'object', 'billing'); // or 'billing'
		$name=$order->cart->$address_type->address_firstname;
		$vars["phone"]=$order->cart->$address_type->address_telephone;
		$vars["email"]=$user->user_email;
		
		$currencyClass = hikashop_get('class.currency');
		$amount = $currencyClass->format($order->order_full_price,$order->order_currency_id);
		$bill=$order->order_full_price;
		
	
	$ship=array(
		'su_id'	=> 'XXX',
		'order_id'=> $order->order_number, 
		'rturl'	=> 'XXX.php', 
		'rv_name'=> $name,
		'rv_email'=> $vars["email"],
		'rv_mobil'=> $vars["phone"],
		'rv_amount'=> $bill,
		'webtemp'=> $amount
	);

        $ez_temp=$_GET['webtemp'];
	
        
	$href='http://www.ezship.com.tw/emap/rv_request_web.jsp';

	if($ez_temp=='')
        {	
	        echo '</br></br>';
		echo 'NOW LINKING TO EZSHIP';
		echo"<form id=ezship method=POST action='".$href."'>\n";
		foreach($ship as $code => $text){
		echo"	<input type='hidden'  name='".$code."'  value='".$text."'>\n";
		}
	
		echo"</form>\n";

		echo"<script>";
		echo"document.forms['ezship'].submit();";
		echo"</script>";
	}


?> 

The linking is almost okay. The only problem is that when I log in to EZSHIP account and I found the buyer's chinese name in the order records is garbled. I don't know how to fix the problem. Please help me.

BTW, I see the OpenCart has the component of EZSHIP, will Hikaship provide it in the near future?

Sincere thanks. :)

Last edit: 11 years 10 months ago by tinachou.

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

  • Posts: 82817
  • Thank you received: 13360
  • MODERATOR
11 years 10 months ago #84254

Hi,

That code sounds ok to me and should not cause that issue.
Try to change type='hidden' to type='text' and see in the fields that are now displayed for your form have the correct text.
If yes, then adding a charset-accept attribute to your form might help:
www.w3schools.com/tags/att_form_accept_charset.asp

If no, then it means that the text is already wrong before your code.

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

Time to create page: 0.058 seconds
Powered by Kunena Forum