ascii

Decoding T-SQL CAST in C#/VB.net

Recently our site has been deluged with the resurgence of the ASPRox bot SQL Injection attack. Without going into details, the attack attempts to execute SQL code by encoding the T-SQL commands in an ASCII encoded BINARY string. It looks something like this: DECLARE%20@S%20NVARCHAR(4000);SET%20@S=CAST(0x44004500...06F007200%20AS%20NVARC...

How do I generate ASCII codes 2 and 3 in a Bash command line?

If I press ctrl-b that ought to give me ASCII code 2, but ctrl-c is going to be interpreted as a Break. So I figure I've got to redirect a file in. How do I get these characters into a file? ...

How do I keep whitespace formatting using PHP/HTML?

I'm parsing text from a file and storing it in a string. The problem is that some of the text in the original files contains ASCII art and whatnot that I would like to preserve. When I print out the string on the HTML page, even if it does have the same formatting and everything, since it is in HTML, the spacing and linebreaks are not ...

Are you fluent in Unicode yet?

Almost 5 years ago Joel Spolsky wrote this article, "The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!)". Like many, I read it carefully, realizing it was high-time I got to grips with this "replacement for ASCII". Unfortunately, 5 years later I feel I have slip...

C# String ASCII representation

How can I insert ASCII special characters (e.g. with the ASCII value 0x01) into a string? I ask because I am using the following: str.Replace( "<TAG1>", Convert.ToChar(0x01).ToString() ); and I feel that there must be a better way than this. Any Ideas? Update: Also If I use this methodology, do I need to worry about unicode & ASCII...

How do you generate passwords?

Random Characters? Passphrases? High Ascii? cat /dev/urandom | strings ...

Why do my keystrokes turn into crazy characters after I dump a bunch of binary data into my terminal?

If I do something like: $ cat /bin/ls into my terminal, I understand why I see a bunch of binary data, representing the ls executable. But afterwards, when I get my prompt back, my own keystrokes look crazy. I type "a" and I get a weird diagonal line. I type "b" and I get a degree symbol. Why does this happen? ...

How can you strip non-ASCII characters from a string? (in C#)

How can you strip non-ASCII characters from a string? (in C#) ...

How to convert a Unicode character to its ASCII equivalent

Here's the problem: In C# I'm getting information from a legacy ACCESS database. .NET converts the content of the database (in the case of this problem a string) to Unicode before handing the content to me. How do I convert this Unicode string back to it's ASCII equivalent? Edit Unicode char 710 is indeed MODIFIER LETTER CIRCUMFLEX A...

How do I translate 8bit characters into 7bit characters? (i.e. Ü to U)

I'm looking for pseudocode, or sample code, to convert higher bit ascii characters (like, Ü which is extended ascii 154) into U (which is ascii 85). My initial guess is that since there are only about 25 ascii characters that are similar to 7bit ascii characters, a translation array would have to be used. Let me know if you can think o...

Ruby: character to ascii from a string

Hi, this wiki page gave a general idea of how to convert a single char to ascii http://en.wikibooks.org/wiki/Ruby_Programming/ASCII But say if I have a string and I wanted to get each character's ascii from it, what do i need to do? "string".each_byte do |c| $char = c.chr $ascii = ?char puts $ascii end It doesn't wo...

Fastest way to convert a possibly-null-terminated ascii byte[] to a string?

I need to convert a (possibly) null terminated array of ascii bytes to a string in C# and the fastest way I've found to do it is by using my UnsafeAsciiBytesToString method shown below. This method uses the String.String(sbyte*) constructor which contains a warning in it's remarks: "The value parameter is assumed to point to an array re...

Character reading from file in Python

In a text file, there is a string "I don't like this". However, when I read it into a string, it becomes "I don\xe2\x80\x98t like this". I understand that \u2018 is the unicode representation of "'". I use f1 = open (file1, "r") text = f1.read() command to do the reading. Now, is it possible to read the string in such a way that wh...

.Net Regex ValidationExpression ASCII

Anyone know a good Regex expression to drop in the ValidationExpression to be sure that my users are only entering ASCII characters? <asp:RegularExpressionValidator id="myRegex" runat="server" ControlToValidate="txtName" ValidationExpression="???" ErrorMessage="Non-ASCII Characters" Display="Dynamic" /> ...

How do I convert a file's format from Unicode to ASCII using Python?

I use a 3rd party tool that outputs a file in Unicode format. However, I prefer it to be in ASCII. The tool does not have settings to change the file format. What is the best way to convert the entire file format using Python? ...

How do I convert a list of ascii values to a string in python?

I've got a list in a Python program that contains a series of numbers, which are themselves ASCII values. How do I convert this into a "regular" string that I can echo to the screen? ...

How to check if a string in Python is in ASCII?

Hello, I am fighting with Python to understand how do I check whether a string is in ASCII or not. I am aware of ord(), however when I try ord('é'), I have TypeError: ord() expected a character, but string of length 2 found. I understood it is caused by the way I built Python (as explained in the ord()'s documentation). So my questio...

Convert text to 7-bit ASCII from command-line

I'm on OS X 10.5.5 (though it does not matter much I guess) I have a set of text files with fancy characters like double backquotes, ellipsises ("...") in one character etc. I need to convert these files to good old plain 7-bit ASCII, preferably without losing character meaning (that is, convert those ellipses to three periods, backqu...

ASCII value of a character in python

How do I get the ASCII value of a character as an int in python? ...

How do I get emacs shell mode to either render (or ignore) my colors instead of printing ASCII codes?

The symptom of the problem looks like "[0m[27m[24m[J[34;1" which on a terminal translates into the color blue. -A ...