为什么现代的Perl默认情况下会避免使用UTF-8?

自古美人都是妖i 提交于 2020-08-05 20:45:18

问题:

I wonder why most modern solutions built using Perl don't enable UTF-8 by default. 我想知道为什么大多数使用Perl构建的现代解决方案默认情况下都不启用UTF-8

I understand there are many legacy problems for core Perl scripts, where it may break things. 我知道核心Perl脚本有很多遗留问题,可能会破坏事情。 But, from my point of view, in the 21 st century, big new projects (or projects with a big perspective) should make their software UTF-8 proof from scratch. 但是,从我的角度来看,在21 世纪 ,大型新项目(或具有大的方面讲项目)应该从头开始他们的软件UTF-8的证明。 Still I don't see it happening. 我仍然看不到它的发生。 For example, Moose enables strict and warnings, but not Unicode . 例如, Moose启用严格和警告,但不启用Unicode Modern::Perl reduces boilerplate too, but no UTF-8 handling. Modern :: Perl也减少了样板,但没有UTF-8处理。

Why? 为什么? Are there some reasons to avoid UTF-8 in modern Perl projects in the year 2011? 有什么理由在2011年的现代Perl项目中避免使用UTF-8?


Commenting @tchrist got too long, so I'm adding it here. 评论@tchrist太长了,因此我在这里添加它。

It seems that I did not make myself clear. 看来我没有说清楚。 Let me try to add some things. 让我尝试添加一些内容。

tchrist and I see situation pretty similarly, but our conclusions are completely in opposite ends. 我和tchrist的情况非常相似,但是我们的结论完全相反。 I agree, the situation with Unicode is complicated, but this is why we (Perl users and coders) need some layer (or pragma) which makes UTF-8 handling as easy as it must be nowadays. 我同意,Unicode的情况很复杂,但这就是为什么我们(Perl用户和编码人员)需要一些层(或杂注)的原因,这使得UTF-8处理如今必须像现在一样容易。

tchrist pointed to many aspects to cover, I will read and think about them for days or even weeks. tchrist指出了要涵盖的许多方面,我将在几天甚至几周内进行阅读和思考。 Still, this is not my point. 不过,这不是我的意思。 tchrist tries to prove that there is not one single way "to enable UTF-8". tchrist试图证明“启用UTF-8”没有唯一的方法。 I have not so much knowledge to argue with that. 我没有太多的知识可以与之争论。 So, I stick to live examples. 因此,我坚持使用实例。

I played around with Rakudo and UTF-8 was just there as I needed . 我打得四处Rakudo和UTF-8只是有我需要的 I didn't have any problems, it just worked. 我没有任何问题,只是工作正常。 Maybe there are some limitation somewhere deeper, but at start, all I tested worked as I expected. 也许在某个更深层次的地方有一些限制,但是一开始,我测试的所有内容都按预期工作。

Shouldn't that be a goal in modern Perl 5 too? 那不是现代Perl 5的目标吗? I stress it more: I'm not suggesting UTF-8 as the default character set for core Perl, I suggest the possibility to trigger it with a snap for those who develop new projects. 我更强调的是:我不建议UTF-8作为Perl核心的默认字符集,我建议那些谁开发项目能够轻松地触发它的可能性。

Another example, but with a more negative tone. 另一个例子,但带有更负面的语气。 Frameworks should make development easier. 框架应该使开发更容易。 Some years ago, I tried web frameworks, but just threw them away because "enabling UTF-8" was so obscure. 几年前,我尝试了Web框架,但由于“启用UTF-8”太模糊了,所以只是将它们扔掉了。 I did not find how and where to hook Unicode support. 我没有找到如何以及在何处钩住Unicode支持。 It was so time-consuming that I found it easier to go the old way. 这太耗时了,我发现走旧路更容易。 Now I saw here there was a bounty to deal with the same problem with Mason 2: How to make Mason2 UTF-8 clean? 现在,我看到这里有悬赏计划来解决与Mason 2相同的问题: 如何使Mason2 UTF-8干净? . So, it is pretty new framework, but using it with UTF-8 needs deep knowledge of its internals. 因此,这是一个非常新的框架,但是将其与UTF-8一起使用需要深入了解其内部。 It is like a big red sign: STOP, don't use me! 就像一个大红色标志:停止,不要使用我!

I really like Perl. 我真的很喜欢Perl。 But dealing with Unicode is painful. 但是处理Unicode是很痛苦的。 I still find myself running against walls. 我仍然发现自己撞墙了。 Some way tchrist is right and answers my questions: new projects don't attract UTF-8 because it is too complicated in Perl 5. tchrist用某种方式正确并回答了我的问题:新项目不会吸引UTF-8,因为它在Perl 5中太复杂了。


解决方案:

参考一: https://stackoom.com/question/Pr8u/为什么现代的Perl默认情况下会避免使用UTF
参考二: https://oldbug.net/q/Pr8u/Why-does-modern-Perl-avoid-UTF-8-by-default
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!