special-characters

Python regex to convert non-ascii characters in a string to closest ascii equivalents

╄→尐↘猪︶ㄣ 提交于 2019-12-18 11:31:56
问题 I'm seeking simple Python function that takes a string and returns a similar one but with all non-ascii characters converted to their closest ascii equivalent. For example, diacritics and whatnot should be dropped. I'm imagining there must be a pretty canonical way to do this and there are plenty of related stackoverflow questions but I'm not finding a simple answer so it seemed worth a separate question. Example input/output: "Étienne" -> "Etienne" 回答1: Reading this question made me go

JavaScript Remove special characters string not working

爱⌒轻易说出口 提交于 2019-12-18 09:37:22
问题 I'm trying to remove special characters that could appear within my Google Analytics tags, as the special characters seem to be causing script errors in some versions of IE. I have this function: function removeSplChars(inStr) { inStr = inStr.replace(/[^a-zA-Z0-9 ]/g, ""); return inStr; } and there is the GA code that currently works: <script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', '<c:out value="${profileId}"/>']); <c:choose> <c:when test="${(lastCmdName eq

Batch: Auto escape special characters

我是研究僧i 提交于 2019-12-18 09:17:55
问题 As far as I know, I need to escape every escape characters when echoing them. The ^ method works fine for a few echo es. (which should be something like:) @echo ^| @echo ^> ^>^> However, when there are a lot of characters to escape, the ^ method won't work anymore. So, my question is: Are there any ways escape all special characters without "spamming" the caret? 回答1: Well, there is no need to escape redirection operators and other special characters listed in last paragraph in help output by

ajax post special characters

ぃ、小莉子 提交于 2019-12-18 05:56:24
问题 How do I pass a a large string containing characters like '%' and '&' to my php page through ajax post? In other words how to javascript-encode them and php-decode them? 回答1: the encodeURIComponent() JavaScript function can be used to escape any of those characters in either the keys or the values. PHP will receive and decode it automatically into the $_POST array. The format of the data should be Query String format, specifically: Content-Type: application/x-www-form-urlencoded For example:

Invalid characters in File.ReadAllText

孤人 提交于 2019-12-18 05:54:19
问题 I'm calling File.ReadAllText() in a program designed to format some files that I have. Some of these files contain the ® (174) symbol. However, when the text is being read, the returned string contains � (65533) symbols where the ® (174) should be. What would cause this and how can I fix it? 回答1: This is likely due to a mismatch in the Encoding . Use the ReadAllText overload which allows you to specify the proper Encoding to use when reading the file. The default overload will assume UTF-8

How to apply a style to a single special HTML character across the page

本秂侑毒 提交于 2019-12-18 05:17:15
问题 We've got a client who want's to superscript to "registered trademark" (®) character across their website. The website is CMS based and not only are they having trouble consistently superscripting characters but the superscript styling doesn't carry across to any CMS generated page titles etc. I'm wondering what are the possible/ best ways to achieve this: Can CSS be used to apply a style to a specific special character? Using jQuery to apply the style post page load. Extending the template

how to insert special character in mysql via php and display on html page

北慕城南 提交于 2019-12-18 04:24:07
问题 how to insert special characters into a database(MySQL) like Registered symbol ( ® ) OR Copyright sign ( © ) OR Trade Mark sign ( ™ ) Also I want to display as original on the html page. What I have to do in both side (front end and back end), please elaborate Which function is more effective? Method 1: $_GET = array_map('trim', $_GET); $_POST = array_map('trim', $_POST); if(get_magic_quotes_gpc()){ $_GET = array_map('stripslashes', $_GET); $_POST = array_map('stripslashes', $_POST); $_GET =

escaping special character in a url

好久不见. 提交于 2019-12-18 04:20:20
问题 I am using a url to open a html page, and i am sending data in querystring withe the page url. For example: abc.html?firstParameter=firstvalue&seconedParameter=seconedvalue Problem is that if firstvalue or secondvalue in parameter contains special character like #,(,),%,{ , then my url is not constructing well. In this case url is not validating. I am doing all this in javascript . Can any body please help me out this. 回答1: You have 3 options: escape() will not encode: @*/+ encodeURI() will

How to allow fulltext searching with hyphens in the search query

╄→гoц情女王★ 提交于 2019-12-18 04:03:13
问题 I have keywords like "some-or-other" where the hyphens matter in the search through my mysql database. I'm currently using the fulltext function. Is there a way to escape the hyphen character? I know that one option is to comment out #define HYPHEN_IS_DELIM in the myisam/ftdefs.h file, but unfortunately my host does not allow this. Is there another option out there? Edit 3-8-11 Here's the code I have right now: $search_input = $_GET['search_input']; $keyword_safe = mysql_real_escape_string(

How to replace decoded Non-breakable space (nbsp)

时光怂恿深爱的人放手 提交于 2019-12-18 04:01:20
问题 Assuming I have a sting which is "a s d d" and htmlentities turns it into "a s d d" . How to replace (using preg_replace) it without encoding it to entities? I tried preg_replace('/[\xa0]/', '', $string); , but it's not working. I'm trying to remove those special characters from my string as I don't need them What are possibilities beyond regexp? Edit String I want to parse: http://pastebin.com/raw/7eNT9sZr with function preg_replace('/[\r\n]+/', "[##]", $text) for later implode("</p><p>",