使用 Intervention/image 为照片添加水印 出现乱码空格
$text = $this->to_unicode('科室ID撒水水水水水水水飒飒');
$image = Image::make('images/as.jpg')->text($text, 50, 50, function($font) {
$font->file(public_path('fonts/FontAwesome.ttf'));
$font->size(20);
$font->align('center');
$font->valign('top');
});
$image->save('images/new_avatar.jpg');
function to_unicode($string)
{
$str = mb_convert_encoding($string, 'UCS-2', 'UTF-8');
$arrstr = str_split($str, 2);
$unistr = '';
foreach ($arrstr as $n) {
$dec = hexdec(bin2hex($n));
$unistr .= '&#' . $dec . ';';
}
return $unistr;
}
请问这是什么情况
这是你要的文字么?
如果不是,为什么不直接使用汉字呢?非要转一下干什么?