PHP中的特殊字符 [英] Special Characters in FPDF with PHP

查看:174
本文介绍了PHP中的特殊字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网络表单,用户可以填写,该内容用FPDF和PHP填充PDF。当用户使用撇号输入单词时,PDF上会出现一个斜杠。



同样,商标符号等特殊字符编码错误。



FPDF常见问题解答说使用:

  $ str = utf8_decode($ str); 

但我不知道如何将它应用到整个PDF。



任何想法?



<$>

p $ p> $ reportSubtitle = stripslashes($ _ POST ['pagesubtitle']);
$ reportSubtitle = iconv('UTF-8','windows-1252',$ reportSubtitle);

然后打印出来:

  $ pdf-> Write(6,$ reportSubtitle); 

这将删除撇号后的任何不需要的斜杠,以及使用'iconv'诸如™


等字符

I have a web form that users can fill out and that content fills up a PDF with FPDF and PHP. When a user enters a word with an apostrophe, a slash appears before it on the PDF.

Similarly, special characters like trademark symbols are encoded wrong.

The FPDF FAQs say to use:

$str = utf8_decode($str);

But I'm just not sure how to apply that to the whole PDF. I'm trying to think about it as if it was an HTML page but that isn't helping.

Any ideas?

解决方案

Figured this out by doing the following (pagesubtitle is the name of the text field in the form):

$reportSubtitle = stripslashes($_POST['pagesubtitle']);
$reportSubtitle = iconv('UTF-8', 'windows-1252', $reportSubtitle);

Then print it out:

$pdf->Write (6, $reportSubtitle);

This will remove any unwanted slashes following apostrophes, as well as use the 'iconv' function to print special characters such as ™

这篇关于PHP中的特殊字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆