I'm developing an application for iPhone, in which I've imported c++ CLucene
library.
Almost all CLucene
functiona require String
as TCHAR*
.
I've some problems in converting NSString
to/from this type of data. I've searched many solution but none worked.
Can you please show me how to make this conversion?
I was able to make library work with test string defined with _T()
macro. However XCode give me:
Conversion from string literal to 'TCHAR *' (aka 'wchar_t *') is deprecated.
Which is the non deprecated method t开发者_C百科o do it?
Thank you!
Edit: I solved this way:
Converting from NSString
to TCHAR*
:
(const TCHAR *) [stringa cStringUsingEncoding:NSUTF32LittleEndianStringEncoding];
Converting from TCHAR*
to NSString
:
[[NSString alloc] initWithBytes:ctc length:wcslen(ctc) * sizeof(TCHAR) encoding:NSUTF32LittleEndianStringEncoding]
thank you!
Following code worked for me:
NSString *pStr = [NSString stringWithFormat:@"%S", GetTCHARString()];
精彩评论