RADPHP完美支持中文的方法
网站上有好多解决RADPHP显示中文的方法,但都是不解决根本问题的方法,RADPHP其实是可以完美的支持中文的,下面是具体方法:
真正解决radphp中文显示问题的方法
radphp是一个很不错的PHP编程器,它的拖拽建立程序的方法非常容易上手,
可是它的测试版对在ANSI编码时的中文无法正常显示,网上有好多文章都说
需要改成UTF8代码才可以显示中文,但是我不这么认为,进过测试,跟踪代码
发现原来是rpcl文件中的类库文件的代码有误,不知道是不是故意为之,因为
我们得到的都是试用版。下面是修正方法;
打开rpcl目录下classes.inc.php文件;找到第387行代码;
(即名为VCLDecodeUnicode的函数)
387行原来是这样的“if(!function_exists(‘mb_convert_encoding’))”
现在把判断条件中的!去掉,
变成“if(function_exists(‘mb_convert_encoding’))”
它的原意是如果php版本中存在’mb_convert_encoding’函数,
则不执行下面的代码,立刻跳转出该函数,
但是加了!的意思就完全反了,所以怎么都不会正确显示中文了。
所以 VCLDecodeUnicode函数应该改成下面这样。
function VCLDecodeUnicode($orgstr)
{
if(function_exists(‘mb_convert_encoding’))
{
return $orgstr;
}
$pattern = ‘/([0-9]+);/’;
preg_match_all($pattern, $orgstr, $matches);
$size = count($matches[0]);
if( $size {
return $orgstr;
}
$rep_tbl = array();
for($i = 0; $i yyyyy
$utf8_str = ”;
if( $dec_val >= 0×0001 && $dec_val 0x07FF )
{
$utf8_str .= chr(0xE0 | (($dec_val >> 12) & 0x0F));
$utf8_str .= chr(0×80 | (($dec_val >> 6) & 0x3F));
$utf8_str .= chr(0×80 | (($dec_val >> 0) & 0x3F));
}
else
{
$utf8_str .= chr(0xC0 | (($dec_val >> 6) & 0x1F));
$utf8_str .= chr(0×80 | (($dec_val >> 0) & 0x3F));
}
}
$rep_tbl[$matches[0][$i]] = $utf8_str;
}
$nwestr = strtr($orgstr, $rep_tbl);
$internal_str = mb_convert_encoding($nwestr, mb_internal_encoding(), ‘UTF-8′);
return $internal_str;
}
这样随便用什么编码都可以正确显示了。
回复讨论(解决方案)
谢谢分享,不过这里使用RADPHP的可能不多,是的,这个东西对简体中文的支持的确有问题。
啥时候能做出更好的呢............
后来经过研究,其实radphp中文已经很好的支持了,只是通过mb_internal_encoding()函数来判别是什么编码,然而GBK和GB2312都是ANSI编码,ANSI编码缺省认为是ISO-8859-1编码,所以只在rpcl.inc.php文件中加入如下代码就可以确保ANSI编码是中文的正确显示了。
===========================================================================
//如果缺省编码为ISO-8859-1时,则设置为GBK编码
if (mb_internal_encoding() == "ISO-8859-1"){mb_internal_encoding("GBK");}
===========================================================================
classes.inc.php文件并没有错,不用改的。
官方解决方案!
http://docwiki.embarcadero.com/RadPHP/en/UTF-8_Setup
官方解决方案!已经测试,确实可行!
http://docwiki.embarcadero.com/RadPHP/en/UTF-8_Setup
用官方的解决方案编码方式必须是UTF-8,用GBK编码是不行的
楼主强大!!!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Tomato Novel is a very popular novel reading software. We often have new novels and comics to read in Tomato Novel. Every novel and comic is very interesting. Many friends also want to write novels. Earn pocket money and edit the content of the novel you want to write into text. So how do we write the novel in it? My friends don’t know, so let’s go to this site together. Let’s take some time to look at an introduction to how to write a novel. Share the Tomato novel tutorial on how to write a novel. 1. First open the Tomato free novel app on your mobile phone and click on Personal Center - Writer Center. 2. Jump to the Tomato Writer Assistant page - click on Create a new book at the end of the novel.

Unfortunately, people often delete certain contacts accidentally for some reasons. WeChat is a widely used social software. To help users solve this problem, this article will introduce how to retrieve deleted contacts in a simple way. 1. Understand the WeChat contact deletion mechanism. This provides us with the possibility to retrieve deleted contacts. The contact deletion mechanism in WeChat removes them from the address book, but does not delete them completely. 2. Use WeChat’s built-in “Contact Book Recovery” function. WeChat provides “Contact Book Recovery” to save time and energy. Users can quickly retrieve previously deleted contacts through this function. 3. Enter the WeChat settings page and click the lower right corner, open the WeChat application "Me" and click the settings icon in the upper right corner to enter the settings page.

Call of Duty Warzone is a newly launched mobile game. Many players are very curious about how to set the language of this game to Chinese. In fact, it is very simple. Players only need to download the Chinese language pack, and then You can modify it after using it. The detailed content can be learned in this Chinese setting method introduction. Let us take a look together. How to set the Chinese language for the mobile game Call of Duty: Warzone 1. First enter the game and click the settings icon in the upper right corner of the interface. 2. In the menu bar that appears, find the [Download] option and click it. 3. Select [SIMPLIFIEDCHINESE] (Simplified Chinese) on this page to download the Simplified Chinese installation package. 4. Return to the settings

In today's society, mobile phones have become an indispensable part of our lives. As an important tool for our daily communication, work, and life, WeChat is often used. However, it may be necessary to separate two WeChat accounts when handling different transactions, which requires the mobile phone to support logging in to two WeChat accounts at the same time. As a well-known domestic brand, Huawei mobile phones are used by many people. So what is the method to open two WeChat accounts on Huawei mobile phones? Let’s reveal the secret of this method. First of all, you need to use two WeChat accounts at the same time on your Huawei mobile phone. The easiest way is to

Mobile games have become an integral part of people's lives with the development of technology. It has attracted the attention of many players with its cute dragon egg image and interesting hatching process, and one of the games that has attracted much attention is the mobile version of Dragon Egg. To help players better cultivate and grow their own dragons in the game, this article will introduce to you how to hatch dragon eggs in the mobile version. 1. Choose the appropriate type of dragon egg. Players need to carefully choose the type of dragon egg that they like and suit themselves, based on the different types of dragon egg attributes and abilities provided in the game. 2. Upgrade the level of the incubation machine. Players need to improve the level of the incubation machine by completing tasks and collecting props. The level of the incubation machine determines the hatching speed and hatching success rate. 3. Collect the resources required for hatching. Players need to be in the game

VSCode Setup in Chinese: A Complete Guide In software development, Visual Studio Code (VSCode for short) is a commonly used integrated development environment. For developers who use Chinese, setting VSCode to the Chinese interface can improve work efficiency. This article will provide you with a complete guide, detailing how to set VSCode to a Chinese interface and providing specific code examples. Step 1: Download and install the language pack. After opening VSCode, click on the left

Setting font size has become an important personalization requirement as mobile phones become an important tool in people's daily lives. In order to meet the needs of different users, this article will introduce how to improve the mobile phone use experience and adjust the font size of the mobile phone through simple operations. Why do you need to adjust the font size of your mobile phone - Adjusting the font size can make the text clearer and easier to read - Suitable for the reading needs of users of different ages - Convenient for users with poor vision to use the font size setting function of the mobile phone system - How to enter the system settings interface - In Find and enter the "Display" option in the settings interface - find the "Font Size" option and adjust it. Adjust the font size with a third-party application - download and install an application that supports font size adjustment - open the application and enter the relevant settings interface - according to the individual

The difference between Go language methods and functions lies in their association with structures: methods are associated with structures and are used to operate structure data or methods; functions are independent of types and are used to perform general operations.
