special-characters

Should we HTML-encode special characters before storing them in the database?

荒凉一梦 提交于 2019-11-28 09:38:15
I use MySQL to store data and my web pages are all encoded as UTF-8. I have a lot of Portuguese characters such as ç and õ and I'm wondering if I should HTML-escape them before storage. Should we store & as & , for example? And why (not)? What are the advantages and disadvantages / best practices? Don't HTML-encode your characters before storage. You should store as pure a form of your data as possible. HTML encoding is needed because you are going to display the data on an HTML page, so do the encoding during the processing of the data to create the page. For example, suppose you decide you

How to escape special characters in a file parsed by PHP parse_ini_file function?

女生的网名这么多〃 提交于 2019-11-28 09:15:21
问题 I'd like to keep a certain string in a configuration file, that is to be parsed by PHP parse_ini_file() function. However, this string contains some special characters (with codes like 0x2C or 0x3D ) that need to be encoded in some way. Is there any way to write a special character with a hex code in such a file? 回答1: The proper way to escape INI values is to enclose them in "double quotes" . If your string doesn't contain double quotes, you can use it in as a value enclosed in double quotes.

Trouble using/displaying special characters from Oracle db in .Net app

一个人想着一个人 提交于 2019-11-28 09:08:58
问题 I have a C#.Net application that accesses data from a commercial application backed by an Oracle 10 db. A couple of fields in the commercial app's database (declared as varchar2(n)) contain special characters. The "smart quote" apostrophe, for example. The commercial client app displays these characters correctly, but my application is displaying them as an inverted question mark. The Oracle character set is "WE8ISO8859P1". My application reads the commercial database using System.Data

Is there a “glyph not found” character?

ⅰ亾dé卋堺 提交于 2019-11-28 09:00:48
Let's assume we have a text that contains a Unicode character that cannot be displayed because our font has no corresponding glyph. Usually, a placeholder is displayed instead, e.g. a rectangular block thingy (see screenshot). Is there a "glyph not found" character that reliably produces this glyph? I'd like to write something like "If the following text contains <insert character here> then you need another font..." in a UI. By the way, I am not talking about � ( replacement character ). This one is displayed when a Unicode character could not be correctly decoded from a data stream. It does

Problems reading CSV file with commas and characters in pandas

人盡茶涼 提交于 2019-11-28 08:43:56
I am trying to read a csv file using pandas and the file has a column called Tags which consist of user provided tags and has tags like - , "", '',1950's, 16th-century. Since these are user provided, there are many special characters which are entered by mistake as well. The issue is that I cannot open the csv file using pandas read_csv. It shows error:Cparser, error tokenizing data. Can someone help me with reading the csv file into pandas? Okay. Starting from a badly formatted CSV we can't read: >>> !cat unquoted.csv 1950's,xyz.nl/user_003,bad, 123 17th,red,flower,xyz.nl/user_001,good,203 ""

XMLHTTP and Special Characters (eg, accents)

早过忘川 提交于 2019-11-28 08:14:59
问题 I am using Microsoft.XMLHTTP via VBA to pull in the body of a web page. In doing so, characters such as é get replaced with "?" or something equally not useful. Here's the basic code: Set objHTTP = CreateObject("Microsoft.XMLHTTP") objHTTP.Open "GET", ThisWebPage, False objHTTP.setRequestHeader "Content-Type", _ "application/x-www-form-urlencoded; charset=UTF-8" objHTTP.Send ("") strResponse = objHTTP.responseText Is there any way to retrieve the page with the special characters intact? Note:

Does At symbol (@) and Dollar Sign ($) has any special meaning in C or C++

怎甘沉沦 提交于 2019-11-28 07:26:34
Recently one of my friend encountered this question in an interview. The interviewer asked him if the special characters like $, @, |, ^, ~ have any usage in c or c++ and where. I know that |, ^ and ~ are used as Bitwise OR, XOR and Complement respectively. But I don't know if @ and $ has any special meaning. If it does, could you please give example where it can be applied? @ is generally invalid in C; it is not used for anything. It is used for various purposes by Objective-C, but that's a whole other kettle of fish. $ is invalid as well, but many implementations allow it to appear in

PHP: Dealing special characters with iconv

天涯浪子 提交于 2019-11-28 07:17:40
I still don't understand how iconv works. For instance, $string = "Löic & René"; $output = iconv("UTF-8", "ISO-8859-1//TRANSLIT", $string); I get, Notice: iconv() [function.iconv]: Detected an illegal character in input string in... $string = "Löic"; or $string = "René"; I get, Notice: iconv() [function.iconv]: Detected an incomplete multibyte character in input string in. I get nothing with $string = "&"; There are two sets of different outputs I need store them in the two different columns inside the table of my database, I need to convert Löic & René to Loic & Rene for clean url purposes. I

How to convert HTML entities like – to their character equivalents?

*爱你&永不变心* 提交于 2019-11-28 06:29:20
I am creating a file that is to be saved on a local user's computer (not rendered in a web browser). I am currently using html_entity_decode , but this isn't converting characters like – (which is the n-dash) and was wondering what other function I should be using. For example, when the file is imported into the software, instead of the ndash or just a - it shows up as – . I know I could use str_replace , but if it's happening with this character, it could happen with many others since the data is dynamic. You need to define the target character set. – is not a valid character in the default

Reading signs like č ć đ š ž from MySql database

眉间皱痕 提交于 2019-11-28 06:25:42
问题 I have problems reading signs 'č', 'ć', 'đ', 'š', 'ž' from MySQL database. I have tried few suggestions that I found on the internet, but none worked. I am looking for correct combination of charset in the database and in PHP file. So far I have always used UTF. 回答1: Use SET CHARACTER SET 'utf8' before querying any data. http://dev.mysql.com/doc/refman/5.0/en/charset-connection.html 回答2: Set table and db charset, collation, etc. to utf8_general_ci After establishing connection from php, be