string to uchar
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 13/02/2004 at 03:33, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 8.100
Platform: Windows ;
Language(s) : C++ ;---------
Hi all
Can anyone tell me how to convert from string to uchar in c++?
Thanks and regards -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 13/02/2004 at 14:57, xxxxxxxx wrote:
That conversion would be lossy, since there are more than one uchar in a string. If you mean that you want to access it as an array of wide uchar, then you can use the [] operator. (E.g. mystring[i].) Or you can use GetCString() to convert it to an 8-bit encoding.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 15/02/2004 at 22:27, xxxxxxxx wrote:
Hi Mikael
Let say now I have this code:
String name = "a";
String szSqlStr1 = ("Insert into Grid(GridName) values('");
szSqlStr1 = szSqlStr1 + name;
szSqlStr1 = szSqlStr1 + ("')");
Can I convert from szSqlStr1 to UCHAR because i have to run this statement..
RETCODE retcode = SQLPrepare (hStmt, szSqlStr1, sizeof(szSqlStr1));
That the second parameter needs the UCHAR type instead of string
Thanks in advance
Regards -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 16/02/2004 at 20:32, xxxxxxxx wrote:
Do something like:
LONG len = szSqlStr1.GetCStringLen(); UCHAR* sqlStr = bNew UCHAR[len+1]; szSqlStr1.GetCString(sqlStr, len+1); RETCODE retcode = SQLPrepare(hStmt, sqlStr, len); // Assuming that len should be without the terminating 0 character
There might be some casts necessary because of UCHAR vs. CHAR. Also, you should check out the different StringEncodings possible.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 19/02/2004 at 01:24, xxxxxxxx wrote:
Mikael, Thanks for the reply.
Now if I have
UCHAR First[128];
SDWORD cbModel;
HSTMT hStmt = NULL;
and I wanna get the data in column 2 of the particular table.
SQLBindCol (hStmt, 2, SQL_C_CHAR, First, sizeof(First), &cbModel);
I can get the result of "First" in UCHAR type. but to be implemented in c++, I need to convert it into String type. Can anyone tell me how to modify this code, so that i can get the String of the result
Thanks in advance -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 19/02/2004 at 19:06, xxxxxxxx wrote:
Coincidentally there's a reverse function for GetCString() named SetCString(). This is how to use it:
String str; str.SetCString(First, -1);
Please see the documentation for more information. Also, there might be some casts necessary because you have to use UCHAR instead of CHAR.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 19/02/2004 at 19:14, xxxxxxxx wrote:
String str;
str.SetCString((CHAR* )First, -1, StXbit);
When i printed in the console. The result of str seems like unknown character. Any hints for me about this? Is this about the encoding?
Thanks and regards -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 19/02/2004 at 19:34, xxxxxxxx wrote:
Have you checked what First contains in the debugger? This code seems to work:
const UCHAR* First = reinterpret_cast<const UCHAR*>( static_cast<const CHAR*>("Hello World!")); String str; str.SetCString(reinterpret_cast<const CHAR*>(First), -1, StXbit); GePrint(str);
(The second static_cast is just for clarity. Formally it isn't necessary.)
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 20/02/2004 at 01:47, xxxxxxxx wrote:
I have tried this, but I got the encoded character in console. Not the real String.
My code is like this:
CHAR First[128];
SQLBindCol (hStmt, 1, SQL_C_CHAR, First, sizeof(First), &cbModel);
const UCHAR* First2 = reinterpret_cast<const UCHAR*>(First);
String str;
str.SetCString(reinterpret_cast<const CHAR*>(First2), -1, StXbit);
GePrint("Res: " + str);
Is that the correct way to do? Any hints for me? Because What i got in the console was the encoded character.
Thanks and regards -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 22/02/2004 at 17:22, xxxxxxxx wrote:
Why are you using UCHAR when both C4D and your SQL functions seem to want CHAR? (You'd save yourself some unnecessary casts by using CHAR.)
What do you mean by "the encoded character"? Your code looks quite correct. Have you had a chance to examine the contents of "First" in your debugger?