FPDF中的克罗地亚语 - PHP [英] Croatian language in FPDF - PHP

查看:74
本文介绍了FPDF中的克罗地亚语 - PHP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好。我需要使用FPDF和PHP在PDF文件中写一些克罗地亚语句子。

我知道这种语言的代码是CP1250或Windows-1250,但它没有正确写出这些类型的字母 - Č,Ć,Š,Ž...。

Hi. I need to write some croatian sentences in PDF file using FPDF and PHP.
I know that the code for this language is CP1250 or Windows-1250 but it doesn't write these types of letters correctly - "Č,Ć,Š,Ž...".






我尝试了什么:



到目前为止,我的代码显然无效:



What I have tried:

So far I have this code which apparently is not working:

$data = iconv('UTF-8', 'CP1250//TRANSLIT', $data);

推荐答案

data = iconv(' UTF-8'' CP1250 // TRANSLIT'


数据);


这是因为CP-1250,以及所有其他代码页编码永远不再使用,完全死了。同时,出于兼容性原因,某些软件(包括操作系统,尤其是Windows)支持此类编码,但主要是间接支持。然而,这些编码本身没有任何作用。当然,尽管支持非Unicode编码,但所有Web都基于Unicode。



Web浏览器通常直接支持大量过时的编码HTTP-EQUIV或meta charset = ......。最好不要买它。



这是我的实用建议:将所有内容转码为UTF-8。此编码不会浪费属于ASCII范围的字符并支持完整的Unicode 字符指令表。这种编码是面向字节的,所有代码点高于0xFF的字符都表示为2个或更多的字节序列;它不依赖于系统的endianess。将您的所有内容转码为UTF-8 离线,不要让它潜入您的网络内容。



切勿使用CP-1251并忘记translit,无论它意味着什么(有几种不同的translit概念)。



现在,你可能有一些克罗地亚文本文件用一些过时的编码写的,但你完全不知道那个编码是什么。这是最简单的检测工具:将文件重命名为.HTML并使用菜单View - >字符编码(或类似项目),并使用不同的编码或使用自动检测。



-SA
This is because CP-1250, as well all other "Code Page" encodings are never used anymore, is totally dead. At the same time, for compatibility reasons, such encodings are supported in some software, including the OS, especially Windows, but mostly indirectly. Nevertheless, nothing works with these encodings natively. And of course, all the Web is also based on Unicode, despite of support of non-Unicode encodings.

Web browsers usually directly support a good number of obsolete encodings via "HTTP-EQUIV" or "meta charset=…". Better don't buy it.

Here is my practical advice: transcode everything to UTF-8. This encoding does not waste space for characters which fall into the ASCII range and supports the full Unicode character repertoire. This encoding is byte-oriented, all characters with code points above 0xFF are expressed as 2 and more byte sequences; it does not depend on endianess of the system. Transcode all your content to UTF-8 offline, don't let it to sneak into your Web content.

Never use CP-1251 and forget about "translit", whatever it means (there are several different notions of "translit").

Now, it's possible that you have some text files in Croatian written in the some obsolete encodings, but you don't know what is that encoding, exactly. Here is the simplest detection tool: rename the file as .HTML and use the menu View -> Character Encoding (or similar item), and play with different encodings or use "auto-detect".

—SA


这篇关于FPDF中的克罗地亚语 - PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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