‎2006 Jan 16 3:45 PM
Can someone please tell me how to convert a non-unicode ascii string to a unicode string in a C program? I have the following code:
char str[128];
sprintf(str, "hello");
rfc_char_t uStr[128];
sprintfU(uStr, cU("%s"), str);
But this doesn't work. When I do a printfU(uStr), I get garbage. PLEASE...how do I do this?
Thanks.
‎2006 Jan 16 8:25 PM
hi,
I'd try to set the locale with
setlocale(LC_ALL, "");before printing unicode strings. otherwise it uses the default locale which is probably ISO-8859-1 or something which cannot display unicode.
just my 2 cents,
anton
‎2006 Jan 16 8:40 PM
That didn't change anything. I can convert from ascii to wide using the mbstowcs / wcstombs functions, but when I try to use these strings in an RFC function, the values are always blank.
Am I posting to the correct forum? I never get any answers to the questions I post here...
Is there any documentation on the UNICODE RFC? I can't find any resouces at all to help me right a Unicode RFC C program, and its getting very frustrating...
‎2006 Jan 16 8:58 PM
Sorry that it didn't help.
Maybe this one gets you further:
<a href="http://help.sap.com/saphelp_nw04/helpdata/en/22/042537488911d189490000e829fbbd/frameset.htm">http://help.sap.com/saphelp_nw04/helpdata/en/22/042537488911d189490000e829fbbd/frameset.htm</a>
Concerning your forum question: I'd say it reads ABAP Programming so you'll find few C programmers in here.
regards,
anton
‎2006 Jan 16 9:59 PM
‎2006 Jan 16 10:16 PM
sorry, i am not your personal butler. I'd try another tone otherwise you soon might not find anyone trying to help you.
over & out.
‎2006 Jan 16 10:32 PM
I am not trying to be nasty. I just wanted to know where to post 'C' questions. The arrangement of forums does not make it very obvious.
‎2006 Jan 17 12:53 AM
There is no separate 'C' forum as that is not the primary focus of this site. Hopefully there is someone out there who knows C as well as ABAP equally well who can answer your question.
If you are calling an ABAP RFC function module, do you think regenerating the stubs using the RFC SDK may generate the code that is unicode compliant? Just a thought.
Srinivas
‎2006 Jan 17 1:43 PM
I believe that the code that genh generated is Unicode compliant. I guess what I'm trying to do is mix Unicode and Ascii in the same program. I have to read an ascii string off a socket. I need to convert the string to an rfc_char_t *, and that is where things are becoming a problem. When I attempt to do that, either with a sprintfU or mbstowcs, the RFC that uses the converted string fails. The same thing happens with the login string I try to build from a config file. So my question really is, how do you convert a chart * to an rfc_chart_t * in the Unicode environment?