Jump to content

UTF-8 Character Replacement


davidannis

Recommended Posts

I am trying to replace the last character in a Japanese word with another. substr_replace did not work - I figured because it was multibyte so I tried using only multibyte functions, but it is still not working. Here's the code I'm trying

<meta charset="utf-8">
<?php 
$word='くたくた';
//substr_replace($word, 'ひ',-1);
$length=mb_strlen ( $word);
$length--;
$word = mb_substr ( $word , $start ,$length).'ひ'; 
echo $word;
?>

Which results in くたく��ひ

I am probably just using the multi_byte functions wrong but can't see how.

Link to comment
https://forums.phpfreaks.com/topic/287421-utf-8-character-replacement/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.