FAQ Database Discussion Community

## Count lines in ASCII file using C

c,ascii,text-files
I would like to count the number of lines in an ASCII text file. I thought the best way to do this would be by counting the newlines in the file: for (int c = fgetc(fp); c != EOF; c = fgetc(fp)) { /* Count word line endings. */ if...

## How to convert ascii / 7bit email to utf8?

php,email,utf-8,ascii,imap

## Conversion from char to int and printing the decimal value

c,char,printf,decimal,ascii
char str[20]; printf("Enter anything\n"); scanf("%s",str); for(int i = 0 ; i<strlen(str) ; i++) { if( isdigit(str[i])) printf("%d",(int)str[i]); } I tried with the above code but the output is in ASCII values of the numbers rather then actual numbers. Like , input: "0" output: "48". When I try (int)(str[i]-'0'); instead of...

## Python-like Byte Array String representation in C#

c#,escaping,bytearray,ascii
Here is the method I am using to get this string representation: public static string ByteArrayToString(byte[] ba, string prefix) { StringBuilder hex = new StringBuilder(ba.Length * 2); foreach (byte b in ba) { if (prefix != null) { hex.Append(prefix); } hex.AppendFormat("{0:x2}", b); } return hex.ToString(); } Here is a sample...

## hex to string chinese,chinese hex 2 byte ,english hex 1byte?

java,string,hex,ascii
this is stringToHexAsciiString. //将字符串转成ASCII十六进制的java方法 public static String stringToHexAsciiString(String value) { StringBuffer sbu = new StringBuffer(); char[] chars = value.toCharArray(); for (int i = 0; i < chars.length; i++) { sbu.append(Integer.toHexString(chars[i])); } return sbu.toString(); } this is asciiToString begin //将ASCII转成字符串的java方法 public static String asciiToString(String value) { StringBuffer sbu = new StringBuffer();...

## Java Conversion from ASCII Integer to Character yields unknown values

java,char,type-conversion,ascii
I have some Java code that should be very simple and straightforward, and unfortunately, I'm getting very odd results. Put simply, I'm doing a basic conversion from ASCII integers back into their string values. For instance, if I do: char n = (char) 152; System.out.print(n); // should yield: ÿ. Unfortunately,...

## Save matrix without the initial tab in ascii-file

matlab,file,ascii
I have a matrix vtx that contains XY coordinates and I want to write it into a file that already exists, with some custom headers. I use the line save('z2.vtx','vtx','-ascii','-append'); to save the matrix in to the specific file. The problem is that I would like each row NOT to...

## I am finding difficulties to solve an expression [closed]

c,variables,ascii
I am finding difficulties to solve an expression please help me to do so. Declare four variables of type char. Initialize one variable to ‘z’. Initialize the other variables to the ASCII integer value for ‘z’, the ASCII octal value for ‘z’, and the ASCII hexadecimal value for ‘z’....

## Convert each letter of string into ascii values - java

java,string,ascii
I want to add two strings and remove duplicate characters of the string then I want to convert each letter of the string into ascii values. After converting, I want to add each letter ascii values and get a total amount of the values.. for ex: ab+ab ab // remove...

## convert ASCII character array to UNICODE string

c#,c,user-interface,unicode,ascii
I am calling a c dll function in c# which returns a 64 bit ASCII character array, since c# uses UNICODE how do I convert the ASCII character array to a UNICODE string? I have done this before by having the string in a struct because the function had a...

## C: Reading a file to keep track of each extended ASCII appearance count

c,ascii
I am currently trying to read the count of each character in a file. The file is encrypted so it contains ascii values 0 to 255. My ultimate goal is to return the character that appeared the most. The Problem After reading through the file I print the array for...

## Matching extended ASCII characters in .NET Regex

c#,regex,ascii,extended-ascii
I'm writing a .NET regular expression that needs to match all ASCII and extended ASCII characters except for control characters. To do this, I consulted the ASCII table and it seems that all these characters have an ASCII encoding of x20 to xFF. So I suppose [\x20-\xFF] should be able...

## Is it possible to make conditions in ASCII? [closed]

ascii
I am working on a software that needs commands in ASCII to define alert thresholds. These thresholds, correspond to a quantity in littre according to a number of gas tank connected each others. Examples : -If it's 1 or 2 tanks the threshold will be 30 L and the ASCII...

## How do I convert a letter to an ASCII value? [closed]

java,char,ascii,value
Let's say char c = s How would I convert S into an ASCII value? ...

## how to put characters combination as constant command into iOS framework

ios,objective-c,unicode,frameworks,ascii
I am new to iOS programming. I am developing some SDK framework right now. I have a command with three characters: 'ESC' 'E' '1', I wanna combine those three characters to generate a NSString and put this NSString into framework. Therefore others can directly use this Constant in framework. Any...

## Matlab: Read textfile with a mix of floats, integers and strings in the same column

matlab,data,ascii
loading a well formatted and delimited text file in Matlab is relatively simple, but I struggle with a text file that I have to read in. Sadly I can not change the structure of the source file, so I have to deal with what I have. The basic file structure...

## Unserialize objects from in-memory ASCII instead of from a file connection

json,r,serialization,ascii
Actual question How can I serialize objects to ASCII and unserialize them again from ASCII without having to write to and read from a file connection (i.e. from ASCII that is in-memory)? Background In a state-less client-server framework, I would like to make certain information persistent accross calls (serialize >>...

## How do i store an (int)string into an int array

c++,arrays,string,ascii
int ascii[1000] = {0}; string *data = (string*)malloc ( 1000*sizeof( string)); char *text = (char*)malloc ( 1000 *sizeof( char)); cout << "Enter the first arrangement of data." << endl; cin.getline(text, 1000); char *token = strtok(text, " "); while ( token != NULL ) { if ( strlen(token) > 0) {...

## Best way to Convert pairs of base 10 integers to ascii characters in python

python,python-2.7,ascii
I am talking to a piece of a test equipment using a serial interface. The two letter ascii ID of the device is encoded as a base 10 integer in a specific register. Each pair of integers needs to be converted to an ascii character. My question is what is...

## Most efficient way to convert ASCII to Binary in x86 Assembly

assembly,binary,x86,ascii
I have a number stored in memory as ASCII and want to convert it to its binary value (multiplied by 100). so 1.23 may be stored in memory in ASCII as 0x312E3233 and this should be converted to the binary value 123. I currently have the following but is there...

## How do I apply CSS style to ASCII character

html,css,styles,ascii,weight
I'd like to reduce the weight of a my ascii degree character &deg; in my html document. Does anybody know how? HTML: <html> <body> <table> <tr> <td> <div style="position:absolute; top: 70; right: 0;"> 72 <span>&deg;</span> F </div> </td> </tr> </table> </body> </html> CSS: body { height: 100%; font-weight: 400; color:...

## How do I generate 8 different random numbers in python?

python,random,ascii
I'm trying to write an encryption program that generates 8 different random numbers and converts them to ASCII. If possible I'd like to use the 'random' function in python, but welcome other help. So far my code for generating the numbers is to assign a value to a different run...

## ASCII Space Character in Ruby Unicode Escape

ruby-on-rails,ruby,unicode,encoding,ascii
Doing some reading and came across this block of code on the topic of Unicode Escapes in Ruby: money = "\u{20AC 20 A3 20 A5}" # => "€ £ ¥" I understand that in this ruby syntax, the actual spaces between the {}'s doesn't output an encoded space, that's the...

## troubles with understanding how ASCII works

encoding,byte,ascii,bit
I have few questions about ASCII encoding: How come there is 127 characters definable in ASCII coding? It should be 7-bit, which means 2 to the power of 7 which equals 128. Where is the one character missing? When I save a textfile as a textfile.txt it should be saved...

## Why extended ASCII (special) characters take 2 bytes to get stored?

c++,c++11,byte,ascii,behavior
ASCII ranging from 32 to 126 are printable. 127 is DEL and thereafter are considered the extended characters. To check, how are they stored in the std::string, I wrote a test program: int main () { string s; // ASCII s += "!"; // 33 s += "A"; // 65...

## Encode an executable file

c++,encoding,ascii
I want to Encode and Decode an executable file The problem is about NULL The file content is MZ(NULL) so the binary code will be 01001101 01011010 00000000 The output should should be: 4d (for M -> 0100 1101) 5a(for Z -> 0101 1010) and 00(for NULL -> 0000 0000)...

## Python - How can I change bytes in a file

python,unicode,binary,ascii,encode
I'm making a encryption program and i need to open file in binary mode to access non-ascii and non-printable characters, i need to check if character from a file is letter, number, symbol or unprintable character. That means i have to check 1 by 1 if bytes (when they are...

## █ character string indexed in python

python,string,unicode,ascii,python-2.x
I'm trying to get the index of 'J' in a string that is similar to myString = "███ ███ J ██" so I use myString.find('J') but it returns a really high value and if I replace '█' by 'M' or another character of the alphabet I get a lower value....

## NSData to NSString losing data

nsstring,ascii,nsdata,nsstringencoding
I'm attempting to convert a binary file into text, the problem is that a large portion of the file was not encoded in ascii and ends up being special characters. I'm using [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding]; but am only getting a few characters back in a 20000 byte data block....

## How to print the ASCII value of a int in C++?

c++,ascii
I'm beginner in c++ and I want to write a program that prints the ASCII value of the alphabet ('a', 'b',.... 'z') and of the numbers ('0'...'9'). I'm able to print the ASCII value of the alphabet using the "int()" function. Example: char a = 'a'; std::cout<<int(a); The result of...

## Regex Latin characters filter and non latin character filer

c#,regex,ascii,non-ascii-chars
I am developing program ,where I need to filter words and sentences which is non Latin character. The problem is, that I found only Latin character words and sentences , but I do not found words and sentences which are mixed with Latin characters and non Latin characters. For ex....

## Building a code for ASCII to binary vice versa in C++ and running into a weird error

c++,string,binary,ascii
I'm building a program to convert ASCII to binary and then binary to ASCII. I've made something so far and the logic seems sound but am running into a error every time I try to compile it. The error is "Binary_reverse' was not declared in this scope". I've tried searching...

## RSA on ASCII message problems with '\0'

encryption,ascii,rsa,null-character
I want to encrypt and decrypt ASCII messages using an RSA algorithm written in assembly. I read that for security and efficiency reasons the encryption is normally not called character-wise but a number of characters is grouped and encrypted together (e.g. wikipedia says that 3 chars are grouped). Let us...

## BeautifulSoup ascii error and csv

python,csv,beautifulsoup,ascii

## DOS ASCII Code pages

ascii,data-conversion,utf,ebcdic
I have a legacy system that is using one EBCDIC to ASCII conversion table. The writer probably did not know that there are multiple code pages for ASCII and EBCDIC. There are extended and accented letters that are not converted properly and I can fix those according to the code...