C/C++ :: Printing Out Unicode Hex As Chars
Feb 10, 2014
I'm writing a school assignment that writes/reads user input into and out of a binary file.
I've gotten the write part to work, but now I need to be able to read that file back in and display it as a string.
I think I should be using fread() and read my file into an array of int's right? But when I try printing out that array I get a whole bunch of numbers that don't match the hex code in my file.
How do I read in a binary file and print it out as a string?
View 4 Replies
ADVERTISEMENT
Feb 5, 2013
I want to print out unicode characters. But I want to do this using the key ids. Example:
int main()
{
std::cout << ('124'); //I would like this to output '|'
}
View 2 Replies
View Related
Apr 9, 2014
I'm trying to write a program which prints a table of ASCII chars, I'm not really done with my thoughts on it but I already
ran into the following error:
Error: cannot initialize a variable of type 'char' with an rvalue of type 'char (*)[16]'
Here's my code so far:
# include <iostream>
using namespace std;
int main() {
char asciiTable = new char[8][16];
int nextSign = 0;
[Code] .....
View 4 Replies
View Related
Jul 10, 2013
I'm trying to print Chinese/unicode characters to a line printer(EPSON LQ-2090) using the writePrinter method in c++.
ANSI characters print fine, but when I throw the buffer of widechar Chinese characters at it, they come out like garbage/ANSI chars.
while debuging string shows chinese characters but in memory it shows ANSI characters not chinese and these ANSI characters are get printed on printer.
Note that if I change the DocInfo datatype parameter to "TEXT" instead of "RAW" then also the Chinese characters donot print.
Is there a way to get Chinese or unicode characters to print correctly?
View 6 Replies
View Related
Aug 29, 2013
I have some code that was compiled without Unicode turned on in the Preprocessor Definitions. I need to access an API that had Unicode turned on in the Preprocessor Definitions (I believe that it is on by default for DLL's) .
I need to call a function in the DLL that requires a structure like:
struct READERINFO {
TCHAR serial[32];
TCHAR altSerial[32];
TCHAR name[32];
TCHAR fccId[48];
TCHAR hwVersion[16];
int swVerMajor;
int swVerMinor;
char devBuild;
};
It returns some information in the structure some of it is Unicode based however the program that is calling it is not Unicode. The preprocessors are not turned on because if they were there would be a lot of things to change in this code. The code is old code that I inherited and now I must interface to some new devices.
I declare my structure as :
READERINFO info; Then I call the function in the DLL which looks like: ApiGetReaderInfo(hAPI, &info, sizeof(into));
Which is defined as:
ApiGetReaderInfo(HANDLE hApi,
Struct READERINFO * ri,
DWORD riSize);
Parameters:
hApiHandle to valid Api object instance
riPointer to the READERINFO structure.
riSizeSize of ri structure in bytes. Usually: sizeof(struct READERINFO).
When I call it from my program that does not have UNICODE defined in the Pre-Processors I get :
Characters like : ÌÌÌÌÌ in the TCHAR fields and invalid numbers in the integer fields.
int ModuleVersion(HANDLE hApi) {
struct READERINFO info;
ApiGetReaderInfo(hApi, &info, sizeof(info));
[Code] ....
When I call it from my program that has some sample code just for this and has the UNICODE defined in the Preprocessors it works just fine. how I can call this from my old code and get the correct information. I have already tried to do the follow without success:
int ModuleVersion(HANDLE hApi) {
#define UNICODE
struct READERINFO info;
#undef UNICODE
ApiGetReaderInfo(hApi, &info, sizeof(info));
[Code] .....
View 4 Replies
View Related
Jan 25, 2015
I'm trying to have a button marked by the sqrt sign, '√'.
I wrote below code and typed that sign by holding down "alt" and typing 251 using numpad. But result is the question mark instead of sqrt mark!
My machine is Windows 7 x86 and IDE is visual studio 2012.
#include <GUI.h>
using namespace Graph_lib;
//---------------------------------
class Test : public Window {
public:
Test(Point, int, int, const string&);
[Code] .....
View 3 Replies
View Related
Aug 11, 2014
You told me that it's better to use UNICODE all the time.
What if the Win32 Api function doesn't have a UNICODE version.
For example CryptProtectData() takes a BYTE (DATA_BLOB *) which is an unsigned char?
[Code] ......
View 7 Replies
View Related
May 20, 2013
I'm looking for a algorithm to search portions of string that have the same caracter. The only possible values are: a,n and g
Char index: 0 1 2 3 4 5 6 7 8 9 RESULT
------------------------------------------
Example 1: a g g g a a 0,4
Example 2: g g g a n n a 0,3
Example 3: a g g g g g g a 0,7
Example 4: g g g g g g g 0,6
Example 5: g g a a g a a a g 0,2,3,5,7,8
View 4 Replies
View Related
Feb 25, 2014
For example if using FindFirstFile(...) it assumes your passing LCPWSTR and not LPCSTR.
I know I can use FindFirstFileA or FindFirstFileW so what is point of default if always UNICODE.
Which brings to my second question. If I say
FindFirstFile("C:", &fdat);
I get error cannot convert parameter 1 from 'const char [7]' to 'LPCWSTR'
I could say WCHAR fName = "C:"; and pass this variable instead. However is there a way to cast "C:" on-the-fly to LPCWSTR, I tried,
FindFirstFile((LCPWSTR)"C:", &fdat);
But it outputs a stream of LONGs to the console instead of filenames.
View 5 Replies
View Related
Sep 13, 2013
I have a problem when i try to save unicode to a .txt file.
I need to store in a file names that will have letters like "ăĂâÂșȘțȚîÎ"
wchar_t name []=L"ăĂâÂșȘțȚîÎ";
FILE* fang;
fang= _wfopen( L"test.txt",L"wt+,ccs=UNICODE");
fwprintf (fang, L"%ls ",name);
When i open my text file i get this: ??âÂ????îÎ
if i use
fang=fopen("test.txt","a");
I get the same result
and for
fang=fopen("ang.txt","a,css=UNICODE");
I get a runtime eroror "invalid file open mode"
View 2 Replies
View Related
Feb 28, 2012
I need to read Unicode characters from a file. The only thing I need to do from them is to extract their Unicode number.
For example if file has u I need to extract its corresponding Unicode number.
View 3 Replies
View Related
Jan 6, 2013
I'm having some problems in receiving fileNames from Server to Client(C++) in Mac OS X. I send a serialized object , which has a char pointer with the fileName or sometimes a string object, when i receive it in the client, it seems to be having %F6 or %E9 ,etc . This issue don't arise in Windows OS though, even thought it's the same code. Is there anyway decoding these '%' characters back to their original form in Mac OS & Linux ..?
Fex characters i got into problems with : ǡ ȅ ȉ
It would be difficult to change the code in server, so if there's a way decoding the characters back to its original form, it would be easier.I'm using Boost Library for Serialization and i'm just looking for ways to decode %F6 back to ȅ in C++, like if some library is available ..?
View 1 Replies
View Related
Nov 7, 2013
I had a file which has name like SIRAO.wav Since this file name has special unicode character all file API's are failed.
I would like to rename this file using Windows API. How can achieve this?
std::string filename variable hold this value as SIRÃO.wav.
I try to read the file using file API after perform a conversion.
Code:
const int utf16_length = MultiByteToWideChar(CP_UTF8,0,filename.data(),filename.length(),NULL,0);
std::wstring utf16;
utf16.resize(utf16_length);
MultiByteToWideChar(CP_UTF8,0,filename.data(),filename.length(),&utf16[0],utf16.length());
const wchar_t *name = utf16.c_str();
rename the file with unicode character?
View 3 Replies
View Related
Sep 23, 2014
This is for homework . Must use only getchar and putchar
Code:
int main(void) {
int pch; //first
int ch; //second
[Code]....
And it works , but i need to hit ENTER two times when i have 3,5,7... chars to print result.
View 6 Replies
View Related
Apr 13, 2013
I'm working on a homework project, and it requires me to read in a file of chars into an array, and then do stuff with that array.
Anyways, I have the first part written, where I'm just trying to read in my data.txt file, and I thought I had it written well. It compiles, but then it seg faults, and I'm not sure why. I used calloc for the array, but maybe I misused it? Or is it in my EOF statement? I'm still not sure if that's coded correctly. I need to get past this so I can start testing the other parts of my code.
Code:
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char* argv[] ) {
/* Local Declarations*/
int i;
int *ptr;
char tempc;
[Code] .....
View 1 Replies
View Related
Sep 27, 2013
I am trying to convert some chars to UTF-8 strings...
Example:
std::string gethex(char c) {
/* EXAMPLE
if (c == 'é')
return "%c3%a9";
I need a function that converts chars like "á, é, í, ã" to UTF-8 hexadecimal strings...
*/
}
[Code] .....
[URL] .... does it. Choose UTF-8, type some character and click 'Url Encode'.
View 14 Replies
View Related
Jul 1, 2014
I am trying to do this but it can never seem to work.
#include <iostream>
using namespace std;
int main () {
char charOne;
cin.get(charOne);
cin.ignore(1000, '
[Code] .....
Basically i want to keep looping until i enter an a or A (also does this apply to if statements as well?)
View 6 Replies
View Related
Apr 10, 2014
I'm trying to put in my messages, in my program, some special chars but when i try something like the following code, i get the output below.
#include <stdio.h>
int main( ) {
printf("Trying this char: %c", 160);
printf("Trying this char: %c", 163);
return 0;
}
Output:
Trying this char: �
Trying this char: �
How can i put those special chars? I would like to use: é, ú, ç, à, Ú, À, ...
View 14 Replies
View Related
Aug 7, 2014
I have a problem with my code. I just have to reverse the chars of a string, but it adds a /n that I can't delete.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Ch05Ex05._5 {
[Code] ....
View 5 Replies
View Related
Mar 31, 2012
I found this method
Code:
TCHAR win_getch()
(below) on a website which is used for printing the characters as the keys on keyboard are hit i-e without hitting the ENTER key. This method is used in a while loop like this
Code:
while ((c = win_getch()) != 13)
{}
I wanted to know why is the character compared to
Code:
13
i-e
Code:
if((c = win_getch()) != 13) then do something
Code:
/**
* This function will simulate the getch() function from conio.h.
* Note that this does not work for special keys like F1-F12, arrow keys,
* even the ESC key does not seem to work with this function.
* @return TCHAR read from input buffer.
*/
TCHAR win_getch() {
DWORD mode;
TCHAR theChar = 0;
[code]....
View 2 Replies
View Related
Mar 8, 2013
Is there any open sources available to do the conversion from UTF8 to Unicode(16-bit) and vice versa..
Also i would like to know how can i integrate that library with my code.
View 1 Replies
View Related
Jul 17, 2013
I am trying to write data in Russian language to the serial (RS-232) port. My display device is already set to that character code page.
But output on the device is not exactly what I require.
My code snippet is like this below
CString pBuffer = L"английский"; //Russian Language
LPBYTE pByte = new BYTE[pBuffer.GetLength() + 1];
memcpy(pByte, (VOID*)LPCTSTR(pBuffer), pBuffer.GetLength());
long nBuffer=pBuffer.GetLength()+1;
DWORD dwWritten=0;
WriteFile(pHandle , pByte, nBuffer ,&dwWritten , NULL);
pHandle is a valid handle.
View 4 Replies
View Related
Dec 22, 2013
I just wonder whether 0xFFFF is a valid Unicode character.
When I using the following code:
CStringW strTempW;
CString strTemp1;
INT_PTR nLen;
strTempW.Format(L"%c", 0xFFFF);
nLen = strTempW.GetLength();
strTemp1 += strTempW;
nLen = strTemp1.GetLength();
After executing the first codeline strTempW.Format(L"%c", 0xFFFF), I will get strTempW of length 1, but cannot see it first character in Visual Studio watch window.
After executing the codelilne strTemp1 += strTempW, I will get strTemp1 of length 0.
Whether 0xFFFF is taken as a valid Unicode or not?
View 1 Replies
View Related
Jan 20, 2014
In my project , we need to create an Array of Unicode Strings . The Array will contain 5000 Strings.
I need to write those strings to a text file which can be opened or edited with NotePad.
Normal _tfopen and fwrite are not able to create notepad compatible .txt file .. I mean the file I created is not readable with Notepad though file open mode is "w+t"
How can I save my unicode strings to a text file
View 6 Replies
View Related
Feb 18, 2014
I am using VC++ 2005, Multibyte char set. I am getting hex values from stream and i have to show it in respective language.
in below example
char mt[] = { 0x0C, 0x85, 0x0C, 0x86, 0x0C, 0x87,0x0C, 0x88,0x0C, 0x89, 0x0C, 0x8A,0x0C, 0x8B,
0x0c, 0x85 , 0x0c , 0x86 , 0x0c , 0x87 , 0x0c , 0x88 , 0x0c , 0x89 , 0x0c , 0x8a , 0x0c , 0x8b , 0x00 , 0x20,
0x0c, 0x8e , 0x0c , 0x8f , 0x0c , 0x90 , 0x0c , 0x92 , 0x0c , 0x93 , 0x0c , 0x94 , 0x00 , 0x20 , 0x0c , 0x95,
0x0c, 0x96 , 0x0c , 0x97 , 0x0c , 0x98 , 0x0c , 0x99 , 0x00 , 0x20 , 0x0c , 0x9a , 0x0c , 0x9b , 0x0c , 0x9c,
0x0c, 0x9d , 0x0c , 0x9e , 0x00 , 0x20 , 0x0c , 0x9f , 0x0c , 0xa0 , 0x0c , 0xa1 , 0x0c , 0xa2 , 0x0c , 0xa3,
0x00, 0x20 , 0x0c , 0xa4 , 0x0c , 0xa5 , 0x0c , 0xa6 , 0x0c , 0xa7 , 0x0c , 0xa8 , 0x00 , 0x20 , 0x0c , 0xaa,
0x0c, 0xab , 0x0c , 0xac , 0x0c , 0xad , 0x0c , 0xae , 0x00 , 0x20 , 0x0c , 0xaf , 0x0c , 0xb0 , 0x0c , 0xb2,
0x0c, 0xb5 , 0x0c , 0xb6};
How can i convert the mt string to below string?
"ಅಆಇಈಉಊಋ ಎಏಐಒಓಔ ಕಖಗಘಙ ಚಛಜಝಞ ಟಠಡಢಣ ತಥದಧನ ಪಫಬಭಮ ಯರಲವಶ"
To cross check the mt array, If you place the above string to the below link you get mt array [URL] ....
Cant i do it in "Multibyte char set" settings? or should i use Unicode settings.
View 3 Replies
View Related
Sep 22, 2012
How to open a file which its name is unicode letters ? usually :
Code:
basic_ifstream<wchar_t> src("source.txt");
Work well to read file with unicode content not filename, so that example doesn't work :
Code:
basic_ifstream<wchar_t> src(L"source.txt");
Also, I have seen some alternatives for using open function but it doesn't work as well.
Code:
basic_ifstream<wchar_t> src;
src.open(L"source.txt");
I use g++ compiler.
View 3 Replies
View Related