0

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 to 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!

Darth Hunterix
  • 1,484
  • 5
  • 27
  • 31
Max
  • 25
  • 8
  • You might want to look at [`this`](http://stackoverflow.com/questions/2610871/how-to-copy-a-wchar-t-into-an-nsstring) and [`this`](http://stackoverflow.com/questions/891594/nsstring-to-wchar-t). – Deepak Danduprolu Jul 04 '11 at 15:55

1 Answers1

0

Following code worked for me:

NSString *pStr = [NSString stringWithFormat:@"%S", GetTCHARString()];
moonlightdock
  • 1,358
  • 13
  • 14