Home Web Front-end JS Tutorial Solution to the problem of garbled page form data in different encodings_javascript skills

Solution to the problem of garbled page form data in different encodings_javascript skills

May 16, 2016 pm 04:13 PM
Garbled characters coding form data page

I encountered a very magical problem today. A user told me that the form on the website here does not get a return value after it is submitted to the query system. The query result is 0 records, but the results of the local pure HTML execution can be searched. to the value. I verified it myself and found that it was indeed the case, and compared the parameters submitted by GET on both sides. Except for the value of one field that was different, the number of parameters was the same, so it was considered that it might be caused by encoding issues.

After opening the two files respectively, I found that the encoding on the two sides was indeed inconsistent, and the server side was GB2312. The parameters passed UTF-8 encoding could not be parsed normally in the past, so I searched and found a rarely used one on the form. properties.

Copy code The code is as follows:

accept-charset=”gb2312″

This attribute is very interesting. You can set the encoding in which the form will encode the content. So, just add this attribute to the form.

But it’s disgusting. IE does not support this attribute, so I had to hack the onSubmit() method of the form and add

Copy code The code is as follows:

onsubmit=”document.charset=’gb2312′;”

The problem is completely solved.
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

Repo: How To Revive Teammates
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to copy a page in Word How to copy a page in Word Feb 20, 2024 am 10:09 AM

Want to copy a page in Microsoft Word and keep the formatting intact? This is a smart idea because duplicating pages in Word can be a useful time-saving technique when you want to create multiple copies of a specific document layout or format. This guide will walk you through the step-by-step process of copying pages in Word, whether you are creating a template or copying a specific page in a document. These simple instructions are designed to help you easily recreate your page without having to start from scratch. Why copy pages in Microsoft Word? There are several reasons why copying pages in Word is very beneficial: When you have a document with a specific layout or format that you want to copy. Unlike recreating the entire page from scratch

How to solve Chinese garbled characters in Linux How to solve Chinese garbled characters in Linux Feb 21, 2024 am 10:48 AM

The Linux Chinese garbled problem is a common problem when using Chinese character sets and encodings. Garbled characters may be caused by incorrect file encoding settings, system locale not being installed or set, and terminal display configuration errors, etc. This article will introduce several common workarounds and provide specific code examples. 1. Check the file encoding setting. Use the file command to view the file encoding. Use the file command in the terminal to view the encoding of the file: file-ifilename. If there is "charset" in the output

How to solve tomcat startup garbled code How to solve tomcat startup garbled code Dec 26, 2023 pm 05:21 PM

Solutions to garbled tomcat startup: 1. Modify Tomcat's conf configuration file; 2. Modify the system language; 3. Modify the command line window encoding; 4. Check the Tomcat server configuration; 5. Check the project encoding; 6. Check the log file; 7 , try other solutions. Detailed introduction: 1. Modify Tomcat's conf configuration file, open Tomcat's conf directory, find the "logging.properties" file, etc.

How to solve the problem of Chinese garbled characters in Windows 10 How to solve the problem of Chinese garbled characters in Windows 10 Jan 16, 2024 pm 02:21 PM

In the Windows 10 system, garbled characters are common. The reason behind this is often that the operating system does not provide default support for some character sets, or there is an error in the set character set options. In order to prescribe the right medicine, we will analyze the actual operating procedures in detail below. How to solve Windows 10 garbled code 1. Open settings and find "Time and Language" 2. Then find "Language" 3. Find "Manage Language Settings" 4. Click "Change System Regional Settings" here 5. Check the box as shown and click Just make sure.

Editing method to solve the problem of garbled characters when opening dll files Editing method to solve the problem of garbled characters when opening dll files Jan 06, 2024 pm 07:53 PM

When many users use computers, they will find that there are many files with the suffix dll, but many users do not know how to open such files. For those who want to know, please take a look at the following details. Tutorial~How to open and edit dll files: 1. Download a software called "exescope" and download and install it. 2. Then right-click the dll file and select "Edit resources with exescope". 3. Then click "OK" in the pop-up error prompt box. 4. Then on the right panel, click the "+" sign in front of each group to view the content it contains. 5. Click on the dll file you want to view, then click "File" and select "Export". 6. Then you can

Solve the problem of garbled characters in win11 notepad Solve the problem of garbled characters in win11 notepad Jan 05, 2024 pm 03:11 PM

Some friends want to open a notepad and find that their win11 notepad is garbled and don't know what to do. In fact, we generally only need to modify the region and language. Win11 Notepad is garbled: First step, use the search function, search and open "Control Panel" Second step, click "Change date, time or number format" under Clock and Region Third step, click the "Manage" option above Card. The fourth step is to click "Change System Regional Settings" below. The fifth step is to change the current system regional settings to "Chinese (Simplified, China)" and click "OK" to save.

How to solve filezilla garbled characters How to solve filezilla garbled characters Nov 20, 2023 am 10:16 AM

Solutions to filezilla garbled characters include: 1. Check the encoding settings; 2. Check the file itself; 3. Check the server configuration; 4. Try other transfer tools; 5. Update the software version; 6. Check for network problems; 7. Seek technical support. To solve the problem of FileZilla garbled characters, you need to start from multiple aspects, gradually investigate the cause of the problem, and take corresponding measures to repair it.

Methods and detailed analysis to solve the problem of garbled characters in some win11 software Methods and detailed analysis to solve the problem of garbled characters in some win11 software Jan 30, 2024 pm 03:54 PM

Many users found that their personal software was garbled after upgrading the win11 system. So how to solve this problem? Now let the editor carefully introduce to users the analysis of garbled code problems in some software in win11. Analysis of garbled characters in some software in win11 1. Click the search box in the taskbar in the lower left corner and enter control panel to open it. 3. Click on the area. 5. Then uncheck the small box for beta version in the window, and finally restart the computer to solve the problem.

See all articles