ascii

"Invalid multibyte char (US-ASCII)" error for ä, ü, ö, ß which are Ascii!

My application needs to handle some international characters, namely ä, ü, ö and ß, which are still ascii. When I tested the behavior of ruby when dealing with these chars, I got this error: test.rb:1: invalid multibyte char (US-ASCII) test.rb:1: invalid multibyte char (US-ASCII) for this code: puts "i like my chars: ä, ü, ö and ß!"...

Python : Text to ASCII & ASCII to text converter program

Hi, i am a newbie to python 2.7 , trying to create a simple program, which takes an input string from the user, converts all the characters into their ascii values, adds 2 to all the ascii values and then converts the new values into text. So for example, if the user input is "test" , the output should be "vguv". This is the code i have...

Read whole text file into matlab variable at once

I would like to read a (fairly big) log file into a matlab string cell in one step. I have used the usual: s={}; fid = fopen('test.txt'); tline = fgetl(fid); while ischar(tline) s=[s;tline]; tline = fgetl(fid); end but this is just slow. I have found that fid = fopen('test.txt'); x=fread(fid,'*char'); is way faster, but i ge...

Why do we use Base64?

Wikipedia says Base64 encoding schemes are commonly used when there is a need to encode binary data that needs be stored and transferred over media that are designed to deal with textual data. This is to ensure that the data remains intact without modification during transport. But is it not that data is always stored/transmitted i...

string starting by ^Bo

Does anybody know what ^Bo means at the beginning of a encoded string? The rest of the string is valid ASCII. Example: "^BoHello" should be interpreted as "Hello" Note: '^B' is the control character 0x02 ...

Print ascii table 0-127

Hello, got a question regarding printing out the 128 first characters from the ascii table. I haven't gotten so far yet, because I already stumbled to a problem. The following code prints the correct value starting from 32-127. From 0 to 31 however it prints out some scrap values. I assume it is correct as well since I quick checkup on t...

Difficulties inherent in ASCII and Extended ASCII, and Unicode Compatibility ?

What are the difficulties inherent in ASCII and Extended ASCII and how these difficulties are overcome by Unicode? Can some one explain me the unicode compatibility? And what does the terms associated with Unicode like Planes, Basic Multilingual Plane (BMP), Suplementary Multilingual Plane (SMP), Suplementary Ideographic Plane (SIP), S...

How do uppercase and lowercase letters differ by only one bit?

I have found one example in Data and Communication Networking book written by Behrouza Forouzan regarding upper- and lowercase letters which differ by only one bit in the 7 bit code. For example, character A is 1000001 (0x41) and character a is 1100001 (0x61).The difference is in bit 6, which is 0 in uppercase letters and 1 in lowercase...

BYTE BCD to ASCII conversion optimization

hello all, I've written a function in c that converts a byte (unsigned char) BCD string into ASCII. Please have look at the code and advice some improvements. Is there any other efficient way that can convert BYTE BCD to ASCII. BYTE_BCD_to_ASC(BYTE *SrcString, char *DesString) { switch (((BCD *)SrcString)->l) { ...

Translating overhead digit in UPC barcode

I've inherited the source to a legacy VB6 barcode library with no documentation. My understanding is it translates an 11-digit number to UPC barcode (I hope I have that right, it might be EAN-8). As far as I can tell, the check digit (right-most trailing number) is calculating correctly, buy the overhead digit (left-most leading number)...

In Java, is it possible to check if a String is only ASCII?

Character.isLetter(c) returns true if the character is a letter. But is there a way to quickly find if a String only contains the base characters of ASCII? ...

Convert ascii code to hexadecimal in UNIX shell script

I'd like to convert ASCII code (like - or _ or . etc) in hexadecimal representation in Unix shell (without bc command), eg : - => %2d any ideas ? ...

sqlite remove non utf-8 characters

I have an sqlite db that has some crazy ascii characters in it and I would like to remove them, but I have no idea how to go about doing it. I googled some stuff and found some people saying to use REGEXP with mysql, but that threw an error saying REGEXP wasn't recognized. Here is the error I get: sqlalchemy.exc.OperationalError: (Ope...

JSF 2.0 Deployment in Netbeans - ASCII and UTF8 problem

I have a problem with the deployment of the jsf application. All the jsp files are encoded as ASCII instead of required UTF8. I'm building the war file on Windows using Netbeans, then I copy it to the Tomcat6 webapp directory. However, when I unpacked the .war file I noticed that those .jsp files are all ASCII. How do I change it in Netb...

How to handle unicode character sequences in C/C++ ?

What are the more portable and clean ways to handle unicode character sequences in C and C++ ? Moreover, how to: -Read unicode strings -Convert unicode strings to ASCII to save some bytes (if the user only inputs ASCII) -Print unicode strings Should I use the environment too ? I've read about LC_CTYPE for example, should I care abou...

Best output type and coding practices for __repr__() functions?

Lately, I've had lots of trouble with __repr__(), format(), and encodings. Should the output of __repr__() be encoded or be a unicode string? Is there a best encoding for the result of __repr__() in Python? What I want to output does have non-ASCII characters. I use Python 2.x, and want to write code that can easily be adapted to Pyt...

Convert a UTF8 string to ASCII in Perl

I've tried everything Google and StackOverflow have recommended (that I could find) including using Encode. My code works but it just uses UTF8 and I get the wide character warnings. I know how to work around those warnings but I'm not using UTF8 for anything else so I'd like to just convert it and not have to adapt the rest of my code t...

What to do with ASCII escape characters in user-generated markup?

I'm using HTML Purifier, a PHP "filter that guards against XSS and ensures standards-compliant output," to sanitize/standardize user-inputted markup. This is an example of the user-inputted markup: <font face="'Times New Roman', Times">TEST</font> which generates: <span style="font-family:&quot;Times New Roman&quot;, Times;">TEST<...

Interview Question, What do they want to accomplish?

I was on a technical job interview today, and it was time to give me some programming exercises. I finally came to the last question: Given the numbers: 116 104 105 115 32 105 115 32 99 111 114 114 101 99 ? What is the next number? To really understand my mindset, I encourage you to stop reading, and really try to figure out what th...

Convert int to ascii and back in Python

I'm working on making a URL shortener for my site, and my current plan (I'm open to suggestions) is to use a node ID to generate the shortened URL. So, in theory, node 26 might be short.com/z, node 1 might be short.com/a, node 52 might be short.com/Z, and node 104 might be short.com/ZZ. Something like that. And when a user goes to that U...