ascii

Safe ASCII char to replace whitespace before storing

My code passes a big bunch of text data to a legacy lib, which is responsible for storing it. However, it tends to remove trailing whitespace. This is a problem when I read the data back. Since I cannot change the legacy code, I thought about replacing the all spaces with some uncommon ASCII character. When I read back the text, I can re...

Convert Decimal to ASCII

I'm having difficulty using reinterpret_cast. Lets just say right off the bat that I'm not married ot reinterpret_cast. Feel free to suggest major changes. Before I show you my code I'll let you know what I'm trying to do. I'm trying to get a filename from a vector full of data being used by a MIPS I processor I designed. Basically w...

ASCII definition of symbol

I've spent hours with no luck on this. In terms of cmd prompt, what does the white filled in square with a 1 followed afterwards mean? e.g. http://i1012.photobucket.com/albums/af249/dororoj/square1.jpg I've tried using string.find() (using C++) with various hex symbols listed on the ascii table at: http://web.cs.mun.ca/~michael/c/asci...

Displaying Unicode/ASCII Characters on console or window

I couldn't display a 'bullet' of character code DEC 149 which can be found on ASCII Chart. cout << char(149) << endl; it comes out as ò on console window. I know a few characters from charmap that I'd like to use but how would i know their character codes? ...

Java check whether file is binary

Hello all. I wrote the following method to see whether particular file contains ASCII text characters only or control characters in addition to that. Could you glance at this code, suggest improvements and point out oversights? The logic is as follows: "If first 500 bytes of a file contain 5 or more Control characters - report it as bi...

UnicodeEncodeError: 'ascii' codec can't encode character when trying a HTTP POST in Python

Hi there, I'm trying to do a HTTP POST with a unicode string (u'\xe4\xf6\xfc') as a paremter in Python, but I receive the following error: UnicodeEncodeError: 'ascii' codec can't encode character This is to the code used to make the HTTP POST (with httplib2) http = httplib2.Http() userInfo = [('Name', u'\xe4\xf6\xfc')] data = ur...

Python write to file

Hello, I've got a little problem here. I'm converting binary to ascii, in order to compress data. All seems to work fine, but when I convert '11011011' to ascii and try to write it into file, I keep getting error UnicodeEncodeError: 'charmap' codec can't encode character '\xdb' in position 0: character maps to Here's my code: b...

What is the equivalent of chr(153) (The TM SYMBOL) in Unicode

In earlier Delphi versions, I could use s:=chr(153); to get a trademark symbol in a string. In Delphi 2010, that doesn't work any longer, perhaps to do with unicode. What is the equivalent code string to put the TM symbol into my string? ...

Query MS SQL for empty spaces(&nbsp; or \xa0)

When exporting some data from MS SQL Server using Python, I found out that some of my data looked like computer \xa0systems which is causing encoding errors. Using SQL Management Studio the row simply appears to be double spaced: computer systems. It seems that this is the code for &nbsp;: how can I query MS SQL Server within managemen...

"Bitwise And" and Left-Padding in C++

I have a macro that looks something like this: Foo(x) ((x - '!') & 070) If I call the following code: Foo('1') => 16 However, if I call the following code: (('1' - '!') & 70) => 0 So my question is, what's going on here? Why does x & 070 compute to x but x & 70 compute to 0? My guess is that the extra 0 on the left is forcing 6...

Python: how to print range a-z?

1. Print a-n: a b c d e f g h i j k l m n 2. Every second in a-n: a c e g i k m 3. Append a-n to index of urls{hello.com/, hej.com/, ..., hallo.com/}: hello.com/a hej.com/b ... hallo.com/n ...

Please explain what this code is doing (someChar - 48)

i'm going through some practice problems, and i saw this code: #include <stdio.h> #include <string.h> int main(void) { char* s = "357"; int sum = 0; int i = 0; for (i = 0; i < strlen(s); i++) { sum += s[i] - 48; } printf("Sum is %d", sum); return 0; } can someone explain what the code does, especially the s...

Need to remove ASCII character

I'm pulling some text from a database, which contains some carriage returns. When I put them straight into html, they get interpreted as � . I've tried a bunch of different ways to remove them, but haven't seemed to have any luck. Any thoughts? ...

Regex any ascii character

What is the regex to match xxx[any ascii char here, spaces included]+xxx? I am trying xxx[(\w)(\W)(\s)]+xxx but it doesn't seem to work. ...

How do I get the int ASCII value of a character in Cocoa?

How do I get the ASCII value as an int of a character in Cocoa? I found an answer for doing this in python, but I need to know how to do this in Cocoa. ( I am still a noob in Cocoa). Python method: use function ord() like this: >>> ord('a') 97 and also chr() for the other way around: >>> chr(97) 'a' how do I do this in Cocoa?...

Graphviz and ascii output

Is it possible to draw ASCII diagram using Graphviz? Something like that: digraph { this -> is this -> a a -> test } Gives following image: But I would like to get ASCII representation: this / \ is a | test Maybe you know other tools which understand dot-files format and can draw ascii diagrams...

Entirely Javascript Ajax spinner?

I was thinking that Ajax spinners are really great but the image spinning is actually shown with some delay OR is loaded too early, I thought maybe I could use these old school characters to provide more accurate ajax activity feedback. |, /, —, \ lets say the target paragraph is called <p id="target"></p> How can I interchange thes...

Python Unicode Encode Error

I'm reading and parsing an Amazon XML file and while the XML file shows a ' , when I try to print it I get the following error: 'ascii' codec can't encode character u'\u2019' in position 16: ordinal not in range(128) From what I've read online thus far, the error is coming from the fact that the XML file is in UTF-8, but Python wants...

In objective-C, I have a NSString with one letter in it. How can I get the ASCII value of that letter?

for example: NSString *foo = @"a"; How can I get the ASCII value of this? (I know it is really 97, but how can I get it using Objective-C?) I guess I can convert it to char but I had no luck with that so far. Sorry for being too nooby! ...

How can I find a single occurrence of a non-latin character using regular expressions?

I am using a regular expression to see if there is a single non-latin character within a string. $latin_check = '/[\x{0030}-\x{007f}]/u'; //This is looking for only latin characters if(preg_match($latin_check, $_POST['full_name'])) { $error = true; } This should be checking to see if there is at least one character pres...