special-characters

How to print non-ascii characters to file in Python 2.7

元气小坏坏 提交于 2019-12-06 08:36:59
I'm trying to obfuscate some javascript by altering their character codes, but I've found that I can't correctly print characters outside of a certain range, in Python 2.7. For example, here's what I'm trying to do: f = open('text.txt','w') f.write(unichr(510).encode('utf-8')) f.close() I can't write unichr(510) because it says the ascii codec is out of range. So I encode it with utf-8. This turns a single character u'\u01fe' into two '\xc7\xbe' . Now, in javascript, it's easy to get the symbol for the character code 510: String.fromCharCode(510) Gives the single character: Ǿ What I'm getting

Python removing extra special unicode characters

 ̄綄美尐妖づ 提交于 2019-12-06 07:19:37
I'm working with some text in python, it's already in unicode format internally but I would like to get rid of some special characters and replace them with more standard versions. I currently have a line that looks like this, but it's getting ever more complex and I see it will eventually bring more trouble. tmp = infile.lower().replace(u"\u2018", "'").replace(u"\u2019", "'").replace(u"\u2013", "").replace(u"\u2026", "") for example the u\2018 and \u2019 are left and right single quotes. Those are somewhat acceptable but for this type of text processing I don't think they are needed. Things

Keep   and other special characters in XSLT output with apply-templates

安稳与你 提交于 2019-12-06 06:45:08
问题 I'm using XSLT to extract some HTML content with special characters (like   ) from an XML file. The content is stored in <content> nodes. I have defined most special characters like this: <!ENTITY nbsp " "> , so this expression works perfectly fine: <xsl:copy-of select="content" disable-output-escaping="yes"/> Now, I want to add target="_blank" to every link found within that content. This is the solution I came up with: <xsl:template match="a" mode="html"> <a> <xsl:attribute name="href"><xsl

How to make the website show signs like “č” and “ć”?

自古美人都是妖i 提交于 2019-12-06 06:02:31
I'm making a website that is in Croatian, and I need to use signs like: "č", "ć", "ž", "đ" and "š". They are currently displayed as little boxes. Info: I use Notepad ++. I set the encoding there to UTF-8. I put the following line of HTML in: <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> However, it does not work. Even Notepad ++ can't display my characters using UTF-8, so that would suggest that I should probably use something else... http://webdesign.maratz.com/lab/utf_table/ Use HTML entities, for example č : č ž : ž This sounds more like a font issue than a character

Method to substitute foreign for English characters in Java?

核能气质少年 提交于 2019-12-06 05:14:12
In PHP I would use this: $text = "Je prends une thé chaud, s'il vous plaît"; $search = array('é','î','è'); // etc. $replace = array('e','i','e'); // etc. $text = str_replace($search, $replace, $text); But the Java String method "replace" doesn't seem to accept arrays as input. Is there a way to do this (without having to resort to a for loop to go through the array)? Please say if there's a more elegant way than the method I'm attempting. A really nice way to do it is using the replaceEach() method from the StringUtils class in Apache Commons Lang 2.4. String text = "Je prends une thé chaud, s

Python subprocess check_output decoding specials characters

霸气de小男生 提交于 2019-12-06 03:29:40
问题 I'm having some issues with python encoding. When I try to execute this: subprocess.check_output("ipconfig", shell=True) it gives me an output with special characters in it, like: "Statut du m\x82dia" "M\x82dia d\x82connect\x82" (i'm french) When I try decoding it with a .decode() at the end, it gives me this error: UnicodeDecodeError: 'utf-8' codec can't decode byte 0x82 in position 78: invalid start byte I tried using .decode("utf-8") , I played around with encoding and decoding for hours,

R how to remove VERY special characters in strings?

不想你离开。 提交于 2019-12-06 03:02:09
问题 I'm trying to remove some VERY special characters in my strings. i've read other post like: Remove all special characters from a string in R? How to remove special characters from a string? but these are not what im looking for. lets say my string is as following: s = "who are í ½í¸€ bringing?" i've tried following: test = tm_map(s, function(x) iconv(enc2utf8(x), sub = "byte")) test = iconv(s, 'UTF-8', 'ASCII') none of above worked. edit: I am looking for a GENERAL solution! I cannot (and

How to embed Unicode Supplementary Private Use characters in CSS generated content?

喜欢而已 提交于 2019-12-06 02:49:10
问题 I'm using a webfont for icons. The icon glyphs are mapped to Unicode's Supplementary Private Use Area-A & B. Everything works fine if I pass characters into CSS via data-* attributes: <div class="icon" data-icon="󰁚"></div> And then: .icon::before { font-family: IconFont; content: attr(data-icon) } But if I try to embed the escaped character directly in CSS... .icon::before { font-family: IconFont; content: '\0F005A '; } It shows up as a missing symbol question mark. But if I try a different

Trying to stop bullets in textareas from entering my database as special characters

为君一笑 提交于 2019-12-06 01:58:48
I am using this currently, but it doesn't seem to be working for bullets: function sanitizeMySQL($var){ $var = mysql_real_escape_string($var); $var = sanitizeString($var); return $var; } function sanitizeString($var) { $var = str_replace('•','•', $var); $var = htmlentities($var); $var = strip_tags($var); return $var; } This is what bullets show up like in my db after someone has submitted them through a textarea: • EDIT: This is now what I am getting: • . I do have bullets stored in my db, so I know it allows them. Is there a correct way to store bullets in latin-1 encoding? The data

How to prevent users from typing special characters in textbox [duplicate]

ぐ巨炮叔叔 提交于 2019-12-06 01:44:58
This question already has an answer here: How do I make a textbox that only accepts numbers? 35 answers Verifying that a string contains only letters in C# 10 answers I need to validate a password entry on a textbox, I have a few demands to fullfill in order to allow the user profile to be created and one of them is to refuse registration if the password contains anything else different than numbers and the alphabet letters the system needs to deny the entry, everything I tried seems to fail. Here is where I'm standing right now: private void BUT_Signup_Click(object sender, EventArgs e) {