ascii

PHP input filtering - checking ascii vs checking utf8

I need to insure that all my strings are utf8. Would it be better to check that input coming from a user is ascii-like or that it is utf8-like? //KohanaPHP function is_ascii($str) { return ! preg_match('/[^\x00-\x7F]/S', $str); } //Wordpress function seems_utf8($Str) { for ($i=0; $i<strlen($Str); $i++) { if (ord($Str[$i]) ...

Displaying the ≥ and ≤ ASCII characters in a C Application

I am currently writing a C application and I need to display the following symbols in the terminal : ≥ and ≤ Their ASCII character codes are 242 and 243 but I can't get them to be displayed in the DOS terminal. Any ideas on how I can do this? ...

Tcl for getting ASCII code for every character in a string

I need to get the ASCII character for every character in a string. Actually its every character in a (small) file. The following first 3 lines successfully pull all a file's contents into a string (per this recipe): set fp [open "store_order_create_ddl.sql" r] set data [read $fp] close $fp I believe I am correctly discerning the ASC...

Convert from English Digits to Arabic ones in html page

I need to convert all English numbers that appear in a given HTML page to Arabic ones (to be independent from the user browser encoding). I prefer to use javascript or it will be great if this can be handled using CSS. I found some pages doing this but I found that the Arabic letters are added with their ASCII representation in the sou...

Detect non-printable characters in JavaScript

Is it possible to detect binary data in JavaScript? I'd like to be able to detect binary data and convert it to hex for easier readability/debugging. After more investigation I've realized that detecting binary data is not the right question, because binary data can contain regular characters, and non-printable characters. Outis's q...

How to remove extended ascii using python?

In trying to fix up a PML (Palm Markup Language) file, it appears as if my test file has non-ASCII characters which is causing MakeBook to complain. The solution would be to strip out all the non-ASCII chars in the PML. So in attempting to fix this in python, I have import unicodedata, fileinput for line in fileinput.input(): prin...

how is 65 translated to 'A' character?

In ASCII, i wonder how is 65 translated to 'A' character? As far as my knowledge goes, 65 can be represented in binary but 'A' is not. So how could this conversion happen? ...

ASCII ART IN WEBBROWSER

How should I do to make it print like it looks in the html document in the web browser? =/ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; <html xmlns="http://www.w3.org/1999/xhtml"&gt; <head> <title>Example</title> </head> <body> ###### # # ## # # #...

encoding a string to ascii

I have a long string that I want to encode to ascii. I'm doing: s = s.encode('ascii', 'replace') but I get: 'ascii' codec can't decode byte 0xc3 in position 2646: ordinal not in range(128) (I've also tried 'ignore' but it doesn't help.) What am I doing wrong?? ...

Issues with Chr(0) in SQL INSERT script

We currently use the SQL Publishing Wizard to back up our database schemas and data, however we have some database tables with hashed passwords that contain the null character (chr(0)). When SQL Publishing Wizard generates the insert data scripts, the null character causes errors when we try and run the resulting SQL - it appears to ign...

Are ASCII characters always encoded the same way in all character encodings?

In ASCII, the character < is encoded as a single-byte character 0x3C, what I'd like to know is that is there a character set where < is encoded differently? I tried UTF-8, it's the same. I tried GB2312 and it's the same... Another question, are all ASCII characters the same in all character sets? ...

US-ASCII encoding with Odd and Even numbers?

I splitted the list of numbers 1-100 to files of 2 bytes. Then, I noticed that each odd number btw 11-99 needs 2 files, ie 4bytes, while each even number btw 11-99 needs 1 file, 2bytes. A file is enough for numbers btw 1-10. You can confirm the finding below. How can you explain the finding? What did I do? save numbers to a file, lik...

Percent Encoded UTF-8 to Ascii(8-bit) conversion

Im reading in urls and they often have percent encoded characters. Example: %C3%A9 is actually é According to http://www.microsystools.com/products/sitemap-generator/faq/character-percentage-url-encoding/ , characters in the upper half of 8-Bit ASCII (128-255) are encoded as UTF-8, then their bytes are saved as hex. Now, when I get my ...

strange codes in text, like +ADs-, +AGA-, or +ACoAKg- and +ACEAIQ-

i got a dataset that uses a strange encoding for non-printables / diacritics. i'm getting hte impression that it's an artifact of some mail system. or maybe it's excel or something? anyway, the stuff i get looks like this: +ADs-, +AGA-, or +ACoAKg- and +ACEAIQ- there's more.... any idea what that this and where it comes from? google sh...

What is the fool proof way to convert some string (utf-8 or else) to a simple ASCII string in python

Inside my python scrip, I get some string back from a function which I didn't write. The encoding of it varies. I need to convert it to ascii format. Is there some fool-proof way of doing this? I don't mind replacing the non-ascii chars with blanks or something else... ...

Japanese Ascii Code

Hi where can I get a list of Ascii codes corresponding to japanese kanji, hiraggana and katakana characters. I am doing a java function and javascript which determines wether it is a japanese character. What is its range in the ASCII code ...

Relation between .NET Encoding and Characterset

What's relation between CharacterSet here: http://msdn.microsoft.com/en-us/library/ms709353%28VS.85%29.aspx and ascii encoding here: http://msdn.microsoft.com/en-us/library/system.text.asciiencoding.getbytes%28VS.71%29.aspx ...

Python: How to get StringIO.writelines to accept unicode string?

I'm getting a UnicodeEncodeError: 'ascii' codec can't encode character u'\xa3' in position 34: ordinal not in range(128) on a string stored in 'a.desc' below as it contains the '£' character. It's stored in the underlying Google App Engine datastore as a unicode string so that's fine. The cStringIO.StringIO.writelines function is t...

Reading characters outside ASCII.

A friend of mine showed me a situation where reading characters produced unexpected behaviour. Reading the character '¤' caused his program to crash. I was able to conclude that '¤' is 164 decimal so it's over the ASCII range. We noticed the behaviour on '¤' but any character >127 seems to show the problem. The question is how would we ...

How to use TRACE with ascii under unicode MFC environment?

I am developing a MFC program under windows CE. It is unicode by default. I can use TRACE to print some message like this TRACE(TEXT("Hey! we got a problem!\n")); It works fine if everything is unicode. But however, I got some ascii string to print. For example: // open the serial port m_Context = CreateFile(TEXT("COM1:"), ...); int ...