InfinityQuest - Programming Code Tutorials and Examples with Python, C++, Java, PHP, C#, JavaScript, Swift and more

Menu
  • Home
  • Sitemap

Python Programming Language Best Tutorials and Code Examples

Learn Python Right Now!
Home
PHP
Setting the Character Encoding of Incoming Data in PHP
PHP

Setting the Character Encoding of Incoming Data in PHP

InfinityCoder December 21, 2016

You want to make sure that data flowing into your program has a consistent character encoding so you can handle it properly.

For example, you want to treat all incoming submitted form data as UTF-8.

You can’t guarantee that browsers will respect the instructions you give them with regard to character encoding, but you can do a number of things that make well-behaved browsers generally follow the rules.

A Content-Type header with a charset is a good hint to a browser that submitted forms should be encoded using the character encoding the header specifies.
Second, include an accept-charset=”utf-8″ attribute in <form/> elements that you output.

Although it’s not supported by all web browsers, it instructs the browser to encode the user-entered data in the form as UTF-8 before sending it to the server.
In general, browsers send back form data with the same encoding used to generate the page containing the form. So if you standardize on UTF-8 output, you can be reasonably sure that you’re always getting UTF-8 input.

The accept-charset <form/> attribute is part of the HTML 4.0 specification, but is not implemented everywhere.

Share
Tweet
Email
Prev Article
Next Article

Related Articles

Creating Methods Dynamically in PHP
You want to dynamically provide methods without explicitly defining them. …

Creating Methods Dynamically in PHP

Indicating Errors and Failures in PHP
You want to indicate that a failure occurred. Return a …

Indicating Errors and Failures in PHP

About The Author

InfinityCoder
InfinityCoder

Leave a Reply

Cancel reply

Recent Tutorials InfinityQuest

  • Adding New Features to bash Using Loadable Built-ins in bash
    Adding New Features to bash Using Loadable …
    June 27, 2017 0
  • Getting to the Bottom of Things in bash
    Getting to the Bottom of Things in …
    June 27, 2017 0

Recent Comments

  • fer on Turning a Dictionary into XML in Python
  • mahesh on Turning a Dictionary into XML in Python

Categories

  • Bash
  • PHP
  • Python
  • Uncategorized

InfinityQuest - Programming Code Tutorials and Examples with Python, C++, Java, PHP, C#, JavaScript, Swift and more

About Us

Start learning your desired programming language with InfinityQuest.com.

On our website you can access any tutorial that you want with video and code examples.

We are very happy and honored that InfinityQuest.com has been listed as a recommended learning website for students.

Popular Tags

binary data python CIDR convert string into datetime python create xml from dict python dictionary into xml python how to create xml with dict in Python how to write binary data in Python IP Address read binary data python tutorial string as date object python string to datetime python

Archives

  • June 2017
  • April 2017
  • February 2017
  • January 2017
  • December 2016
  • November 2016
Copyright © 2021 InfinityQuest - Programming Code Tutorials and Examples with Python, C++, Java, PHP, C#, JavaScript, Swift and more
Programming Tutorials | Sitemap