ZK submits textbox inside odd several Chinese characters garbled problem __ garbled problem

Source: Internet
Author: User

Younger brother recently in learning to use ZK technology, found that the text filled in the textbox to produce odd Chinese characters garbled problem, no positive solution, all day unhappy ....

Odd character garbled problem produced by: ZK Ajax submitted in the TextBox in Chinese using UTF-8 urlencode encoding, passed to the server and then adopted GBK UrlDecode, it will produce this problem.

Online said to fill a full-width space, found that if mixed with Chinese characters English is not good, so I used a more awkward approach:

<textbox visible= "false" id= "Nickname2" width= "150px"/> <textbox action= "onblur:#{nickname2}.value=#{ Nickname}.value;#{nickname}.value=encodeuri (#{nickname}.value); Action.show (#{nickname2}); Action.hide (#{ Nickname}); "Id=" nickname "value=" "width=" 150px "/>

Define 2 textbox, one hidden, one display, the first to display the textbox to enter the Chinese characters nickname, put another hidden nickname2, but the input of Chinese characters finished, focus removal, triggering the onblur JS event, The contents of the nickname in the Nickname2, and the contents of the nickname with JS URL code, and then the nickname hidden

When submitted, the contents of the nickname are submitted to the server, and the server decodes the content.

Although this method to solve the garbled problem, but it is very awkward, hope to get the solution of the friend can sue ... A lot!

Put a system screenshot with ZK::


---------------

Supplemented, after a period of use, found that if returned to nickname to edit, will cause the edit invalid, therefore, the supplementary method is:

<textbox rows= "5" cols= "action=" "onfocus:#{content2}.value=" #{content}.value=decodeuri (#{content}.value); Action.show (#{content}); Action.hide (#{content2}); "Visible=" false "id=" Content2 "width=" 150px "/>
<textbox rows= "5" cols= "action=" Onblur:#{content2}.value=#{content}.value;#{content}.value=encodeuri (#{ Content}.value); Action.show (#{content2}); Action.hide (#{content}); "id=" Content "value=" "width=" 150px "/>

Get the focus and then decode it back.

Another thing to add is that if you put a textbox in a form, it can cause action.show action.hide to be ineffective, not knowing why, and avoiding it.

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.