First off, this is NOT a duplicate of: http://stackoverflow.com/questions/1911053/turn-a-c-string-with-null-bytes-into-a-char-array , because the given answer doesn't work when the char *'s are Unicode.
I think the problem is that because I am trying to use UTF-8 encoded char *'s instead of ASCII char *'s, and the length of each charact...
Please, how can I find out the length of a variable of type wchar_t* in c++?
code example below:
wchar_t* dimObjPrefix = L"retro_";
I would like to find out how many characters dimObjPrefix contains
...
What is the clean way to do that in C?
wchar_t* ltostr(long value) {
int size = string_size_of_long(value);
wchar_t *wchar_copy = malloc(value * sizeof(wchar_t));
swprintf(wchar_copy, size, L"%li", self);
return wchar_copy;
}
The solutions I came up so far are all rather ugly, especially allocate_properly_size_whar_t u...
I'm writing a logging class that uses a templatized operator<< function. I'm specializing the template function on wide-character string so that I can do some wide-to-narrow translation before writing the log message. I can't get TCHAR to work properly - it doesn't use the specialization. Ideas?
Here's the pertinent code:
// Log.h head...
The goal is to avoid copying the string data when I need a const wchar_t*.
The answer seems to be yes, but the function PtrToStringChars doesn't have its own MSDN entry (it's only mentioned in the KB and blogs as a trick). That made me suspicious and I want to check with you guys. Is it safe to use that function?
...
This happens on OS X, though I suspect it applies to any UNIX-y OS.
I have two strings that look like this:
const wchar_t *test1 = (const wchar_t *)"\x44\x00\x00\x00\x73\x00\x00\x00\x00\x00\x00\x00";
const wchar_t *test2 = (const wchar_t *)"\x44\x00\x00\x00\x19\x20\x00\x00\x73\x00\x00\x00\x00\x00\x00\x00";
In the debugger, test1 look...
I get argv as wchar_t** (see below), because I need to work with unicode, but I need to convert it to char **. How can I do that?
int wmain(int argc, wchar_t** argv)
{
...
I'm modifying someone else's code which uses TCHAR extensively. Is it better form to just use std::wstring in my code? wstring should be equivalent to TString on widechar platforms so I don't see an issue. The rationale being, its easier to use a raw wstring than to support TCHAR... e.g., using boost:wformat.
Which style will be more c...
I'm working with unicode/wide characters and I'm trying to create a toString method (Java ::toString equiv). Will ostream handle wide characters, if so is there a way to warn the consumer of the stream that it is unicode coming out of it?
...
Hi,
I've been trying to use the cpw library for some graphics things. I got it set up, and I seem to be having a problem compiling.
Namely, in a string header it provides support for unicode via
#if defined(UNICODE) | defined(_UNICODE)
#define altstrlen wstrlen
#else
#define altstrlen strlen
Now, there's no such thing as wstrlen o...
what is the equivalent function for isalpha or isalnum using wchar_t?
wctype ?
an example would be nice also
thanks
...
---- PLEASE CLOSE ----
------ Edit ---------
I found where the problem is. I'm going to start a new question for the real problem ....
----------------------
Hi,
My Situation:
Linux (Ubuntu 10.04)
gcc
But it has to be platform independent
I have a text file (UTF-8) with special characters like ¥ © ® Ỳ È Ð. I have a std:...
I am doing some serial port communcation to a computer controlled pump and the createfile function I used to communicate requires the com port name to be parsed as a wchar_t pointer.
I am also using QT to create a form and aquire the com port name as a QString.
This QString is converted to a char array and pointed to as follows:
c...
Hello,
I need to convert a QChar to a wchar_t
I've tried the following:
#include <cstdlib>
#include <QtGui/QApplication>
#include <iostream>
using namespace std;
int main(int argc, char** argv) {
QString mystring = "Hello World\n";
wchar_t myArray[mystring.size()];
for (int x=0; x<mystring.size(); x++)
{
my...
Hello I have a pump class that requires using a member variable that is a pointer to a wchar_t array containing the port address ie: "com9".
The problem is that when I initialise this variable in the constructor my compiler flags up a depreciated conversion warning.
pump::pump(){
this->portNumber = L"com9";}
This works fine but th...
I am trying to create a simple datastructure that will make it easy to convert back and forth between ASCII strings and Unicode strings. My issue is that the length returned by the function mbstowcs is correct but the length returned by the function wcslen, on the newly created wchar_t string, is not. Am I missing something here?
typed...