Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to using wcsncpy_s on BCB

54 views
Skip to first unread message

James5950

unread,
Mar 4, 2008, 1:32:11 AM3/4/08
to
Hello Sir,

Why can not use VC API command wcsncpy_s in BCB2007? Have something need
include?

Have any command instead?

Thanks for any comments,

James


Thomas

unread,
Mar 4, 2008, 1:27:46 AM3/4/08
to

Hello James

The VC "wcsncpy" function is the UNICODE version of "strncpy". As far as I know unicode is not supported by CPP Builder or not complete supported. I'm not in the CPP Builder thing so deep anymore, but in the past UNICODE was not very easy with BCB. I think the VCL is not UNICODE capable...

Under VC you must have "_UNICODE" defined to use UNICODE. Maybe this helps you also with BCB

Hope I could help a little bit?

Greetz

Thomas

James5950

unread,
Mar 4, 2008, 7:25:59 AM3/4/08
to
Hello Darko & Thomas

Thanks for your informat, that is very helpful for me.

James

Darko Miletic

unread,
Mar 4, 2008, 7:09:55 AM3/4/08
to
James5950 wrote:
> Hello Sir,
>
> Why can not use VC API command wcsncpy_s in BCB2007? Have something need
> include?

wcsncpy_s is not an API, it is a function from microsoft C RTL. You can
not use this in BDS since it has different C RTL that does not implement
this function.


>
> Have any command instead?

You can use wcsncpy that exists in BDS C RTL.

Just include string.h or cstring.

Remy Lebeau (TeamB)

unread,
Mar 4, 2008, 1:00:20 PM3/4/08
to

"Thomas" <nom...@invalid.invalid> wrote in message
news:47ccf9f2$1...@newsgroups.borland.com...

> The VC "wcsncpy" function is the UNICODE version of "strncpy".

Yes, it is, and it is supported by BCB as well. Most of the Unicode
functions of the C library are.

> As far as I know unicode is not supported by CPP Builder

To an extent, it is.

> in the past UNICODE was not very easy with BCB.

The UNICODE define, no. But Unicode in general can be used.

> I think the VCL is not UNICODE capable...

No it is not. That will be implemented in the next version.

> Under VC you must have "_UNICODE" defined to use UNICODE.

That is not needed in order to use the Unicode functions of the C library.


Gambit


David Dean [CodeGear]

unread,
Mar 4, 2008, 5:07:56 PM3/4/08
to
In article <47cd...@newsgroups.borland.com>,
Darko Miletic <kik...@fibertel.com.ar> wrote:

> Just include string.h or cstring.

If you use cstring, then the function will be in the std:: namespace.
--
David Dean (CodeGear)
Lead C++ QA Engineer

James5950

unread,
Mar 7, 2008, 3:54:36 AM3/7/08
to
>> Just include string.h or cstring.
>
> If you use cstring, then the function will be in the std:: namespace.

The original code like this :

wcsncpy_s(pszBuffer, bufferLen, varName.pwszVal, _TRUNCATE);

I don't know how to use std::namspace to modify this code for compiler?
Please provide easy code explain for me, thank you.

Best regards,
James

Darko Miletic

unread,
Mar 7, 2008, 6:20:11 AM3/7/08
to
James5950 wrote:
> I don't know how to use std::namspace to modify this code for compiler?
> Please provide easy code explain for me, thank you.

No need for that. This code is equivalent to the original:

wcsncpy(pszBuffer, varName.pwszVal, bufferLen);

James5950

unread,
Mar 7, 2008, 6:37:15 AM3/7/08
to
Thanks for your answer.

"Darko Miletic" <kik...@fibertel.com.ar> 在郵件
news:47d124f7$1...@newsgroups.borland.com 中撰寫...

James5950

unread,
Mar 7, 2008, 7:07:04 AM3/7/08
to
Hello All,

The MS function use WCHAR for filename.
For example :
void Player::SetWaveFile(WCHAR *pszFileName)
How to change my OpenDialog->FileName AnsiString to WCHAR?
Have any method translate String to UNICODE?

Thanks for any comments,
James

"Darko Miletic" <kik...@fibertel.com.ar> 在郵件
news:47d124f7$1...@newsgroups.borland.com 中撰寫...

0 new messages