[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Patch] Replace deprecated WSAStringToAddressA
[Thread Prev] | [Thread Next]
- Subject: Re: [Patch] Replace deprecated WSAStringToAddressA
- From: Chris Ruehl <chris.ruehl@xxxxxxxxxxxx>
- Reply-to: libssh@xxxxxxxxxx
- Date: Thu, 8 Jun 2017 11:23:07 +0800
- To: libssh@xxxxxxxxxx
On Thursday, June 08, 2017 03:35 AM, Jason Curl wrote:
Hi, This is not the preferred way of doing things and will only work if you're American because you only need character codes in the ASCII range 32-126. I have a number of comments regarding this post. 1) If the libssh.org API expects C-strings as inputs to its functions, please keep it that way. It's one thing to remove an API or make it obsolete, it's far worse to change the meaning of buffers from an ANSI (multibyte utf-8) to UTF16. Which is why I think the comment from Aris is correct. 2) The sample below is wrong. See [1] on how to do this properly. You have to convert from utf8 to utf16 to use a W function. [1] https://msdn.microsoft.com/en-us/library/ms235631.aspx Regards, Jason. -----Original Message----- From: Chris Ruehl [mailto:chris.ruehl@xxxxxxxxxxxx] Sent: Wednesday, 7 June 2017 08:41 To: libssh@xxxxxxxxxx Subject: Re: [Patch] Replace deprecated WSAStringToAddressA On Wednesday, June 07, 2017 02:32 PM, Chris Ruehl wrote:On Wednesday, June 07, 2017 02:09 PM, Aris Adamantiadis wrote:On 7/06/17 07:40, Chris Ruehl wrote:- rc = WSAStringToAddressA((LPSTR) str, + rc = WSAStringToAddressW((LPWSTR) str,Hi Chris, Does the cast from char * to LPWSTR really work that way? I'm not very well experienced in Windows programming but if I recall properly you're supposed to convert the C string into a unicode wide string before using the -W family functions. Am I mistaken? Thanks, ArisI'd linked it with my application where I use the pure IP-address to connect to a host. Verified its works well. I used QTCreator which shows the parameter list so I used it for the cast. I don't want to open the box and change all to wchar_t :o) Chrissize_t size = strlen(str); wchar_t* wArr = new wchar_t[size]; for (size_t i = 0; i < size; ++i) wArr[i] = str[i]; and using wArr for str in the function without a cast Chris
Jason, you right. that sample code isn't working for C its a snipset from Stack overflow. I don't mind drop the patch - I will follow your link to msdn to see how to properly do it. Chris
[Patch] Replace deprecated WSAStringToAddressA | Chris Ruehl <chris.ruehl@xxxxxxxxxxxx> |
Re: [Patch] Replace deprecated WSAStringToAddressA | Aris Adamantiadis <aris@xxxxxxxxxxxx> |
Re: [Patch] Replace deprecated WSAStringToAddressA | Chris Ruehl <chris.ruehl@xxxxxxxxxxxx> |
Re: [Patch] Replace deprecated WSAStringToAddressA | Chris Ruehl <chris.ruehl@xxxxxxxxxxxx> |
RE: [Patch] Replace deprecated WSAStringToAddressA | Jason Curl <jason@xxxxxxxxxxxxxxxxxxxxxxxx> |