For example, in a simple console application:
Would it be possible to have a user enter text, the code then interpets it's value in Unicode (I guess 8 would be the simplest), then takes the Unicode value and outputs (or stores in another variable) the result?

I guess this would be sort of like a Text to Unicode converter, but that's not the code I'm trying to work toward (hence my "stores in another variable")

Any help, or simply stating that this would be impossible/improbable would be much appreicated. I'm new to CPP and working to learn it on my own time, so I don't have much help.

Recommended Answers

All 3 Replies

Are you talking about the digits of a number stored as text? Like this:

#include <iostream>
#include <string>
#include <wchar.h>
#include <cstdlib>
using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
    std::wstring iobuf;
    cout << "Enter a number\n";
    getline(wcin,iobuf);
    wcout << iobuf << "\n";
    int n = _wtol(iobuf.c_str());
    cout << "n = " << n << "\n";
	return 0;
}

I suppose that could work for what I'm trying to get at, however for some reason my compiler won't accept anything wide in <iostream> right now, so I'll have to get back to this later.

I'm sorry if I worded it awkwardly, I seem to have a problem expressing problems in C++.

what compiler and operating system are you using? The code I posted is just standard c++ stuff, nothing compiler specific about it. And do you want to do this in English or some other language?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.