RADPHP perfectly supports Chinese-php Tutorial

Source: Internet
Author: User
RADPHP perfectly supports Chinese. There are many methods on the website to solve RADPHP's display of Chinese, but they all do not solve the fundamental problem. RADPHP actually supports Chinese perfectly, the specific method is as follows:

Solution to radphp Chinese display problems
Radphp is a very good PHP programmer, and its drag-and-drop method to build a program is very easy to use,
However, its test version cannot be normally displayed for Chinese characters during ANSI encoding. many articles on the Internet have said
You need to change the UTF8 code to display Chinese characters, but I don't think so. I have tested and tracked the code.
I found that the code of the class library file in the original rpcl file is incorrect. I don't know if it is intentional because
All we get is the trial version. The following is a correction method;
Open the classes. inc. php file in the rpcl directory and find the 387th line of code;
(That is, the function named VCLDecodeUnicode)
Row 387 is like this: "if (! Function_exists ('MB _ convert_encoding '))"
Now, in the condition! Remove,
To "if (function_exists ('MB _ convert_encoding '))"
If the php version contains the 'MB _ convert_encoding 'function,
Skip the function immediately without executing the following code,
But added! The meaning is completely reversed, so it cannot be correctly displayed in Chinese.
Therefore, the VCLDecodeUnicode function should be changed to the following.
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 <= 0)
{
Return $ orgstr;
}

$ Rep_tbl = array ();
For ($ I = 0; $ I yyyyy
$ Utf8_str = ";
If ($ dec_val> = 0x0001 & $ 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;
}

In this way, any encoding can be correctly displayed.


Reply to discussion (solution)

Thanks for sharing, but RADPHP may not be used here. Yes, there is indeed a problem with support for simplified Chinese.

When can we make it better ............

Later, after research, in fact, radphp is well supported in Chinese. it only uses the mb_internal_encoding () function to identify the encoding. However, both GBK and GB2312 are ANSI encoded, ANSI encoding is considered as ISO-8859-1 encoding by default, so only in rpcl. inc. add the following code to the PHP file to ensure that the ANSI code is correctly displayed in Chinese.
========================================================== ==========================================
// If the default encoding is ISO-8859-1, it is set to GBK encoding
If (mb_internal_encoding () = "ISO-8859-1") {mb_internal_encoding ("GBK ");}

========================================================== ==========================================

There is no error in the classes. inc. php file. you do not need to change it.

Official solution!

Http://docwiki.embarcadero.com/RadPHP/en/UTF-8_Setup

Official solution! It has been tested and is feasible!
Http://docwiki.embarcadero.com/RadPHP/en/UTF-8_Setup

The official solution encoding method must be UTF-8, and GBK encoding is not acceptable

Powerful landlord !!!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.