1

Topic: CString in char []

How a line CString to convert in char []? Thanks!

2

Re: CString in char []

Hello, indee, you wrote: I> As a line CString to convert in char []? GetBuffer (), GetBufferSetLength () Only it will be not char [], and TCHAR []. If it is necessary char [] in  a variant conversion WideCharToMultiByte is required still ().

3

Re: CString in char []

Hello, indee, you wrote: I> As a line CString to convert in char []? I> Thanks! In TCHAR it is possible, therefore as depending on that UNICODE the project or not CString stores either a char-line or a wchar_t-line CString str = _T ("qwe"); const TCHAR* q = (LPCTSTR) str; Generally it is possible is even easier: CString str = _T ("qwe"); const TCHAR* q = str;

4

Re: CString in char []

Hello, indee, you wrote: I> As a line CString to convert in char []? 0. For what purpose? 1. If  it is ungeared, inside CString the array char' will lie. Look methods GetString () or GetBuffer (). 2. If  it is included, in CString "wide" characters. Then or  to char* (there will be an access by the line at level of bytes), or it is necessary to convert at ansi-line (WideCharToMultiByte in the help).

5

Re: CString in char []

Hello, Maniacal, you wrote: M> Hello, indee, you wrote: I>> As a line CString to convert in char []? I>> Thanks! M> in TCHAR it is possible, therefore as depending on that UNICODE the project or not CString stores either a char-line or a wchar_t-line M> M> CString str = _T ("qwe"); M> const TCHAR* q = (LPCTSTR) str; M> Error (active) E0413 no suitable conversion function from "CString" to "LPCSTR" exists M> Generally it is possible is even easier: M> M> CString str = _T ("qwe"); M> const TCHAR* q = str; M> Error C1001 An internal error has occurred in the compiler

6

Re: CString in char []

Hello, indee, you wrote: M>> In TCHAR it is possible, therefore as depending on that UNICODE the project or not CString stores either a char-line or a wchar_t-line M>> M>> CString str = _T ("qwe"); M>> const TCHAR* q = (LPCTSTR) str; M>> I> Error (active) E0413 no suitable conversion function from "CString" to "LPCSTR" exists LPC TSTR it is necessary to be more attentive. LPCSTR = const char* LPCTSTR = const TCHAR* LPSTR = char* LPTSTR = TCHAR*

7

Re: CString in char []

For what purpose? OLE-> JNI

8

Re: CString in char []

Hello, indee, you wrote: I> For what purpose? OLE-> JNI in Java lines  (utf16). To begin with it is necessary to be defined, what exactly it is necessary to receive - an array byte, ANSI a line, utf-8 or utf-16? About JNI write that any subset 8 for which is own  there is used, but to understand laziness.

9

Re: CString in char []

From OLE I receive CString.

10

Re: CString in char []

Hello, indee, you wrote: I> From OLE I receive CString. With  all is clear, what it is necessary to feed in JNI? What should lie in char []?

11

Re: CString in char []

Hello, V. Zudin, you wrote: SVZ> Hello, indee, you wrote: I>> From OLE I receive CString. SVZ> With  all is clear, what it is necessary to feed in JNI? What should lie in char []? In char [] should lie CString

12

Re: CString in char []

Hello, indee, you wrote: SVZ>> With  all is clear, what it is necessary to feed in JNI? What should lie in char []? I> in char [] should lie CString Mdja, more exhaustively. If UCS2 (UTF16) arranges, then here so: CString str; char* pBytes = (char *) str. GetString (); size_t length = sizeof (TCHAR) * str. GetLength (); pBytes specifies in the first byte of a line which lies in CString. length - length bytes.

13

Re: CString in char []

Hello, V. Zudin, you wrote: SVZ> Hello, indee, you wrote: SVZ>>> With  all is clear, what it is necessary to feed in JNI? What should lie in char []? I>> in char [] Mdja, should lie CString SVZ> more exhaustively. SVZ> if UCS2 (UTF16) arranges, then here so: SVZ> SVZ> CString str; SVZ> char* pBytes = (char *) str. GetString (); SVZ> size_t length = sizeof (TCHAR) * str. GetLength (); SVZ> Error C1001 An internal error has occurred in the compiler

14

Re: CString in char []

Hello, indee, you wrote: SVZ>> If UCS2 (UTF16) arranges, then here so: SVZ>> SVZ>> CString str; SVZ>> char* pBytes = (char *) str. GetString (); SVZ>> size_t length = sizeof (TCHAR) * str. GetLength (); SVZ>> I> Error C1001 An internal error has occurred in the compiler And it any more to me, and to the chief of transport shop. Or  the project or to reinstall/update the compiler.

15

Re: CString in char []

Hello, indee, you wrote: I> As a line CString to convert in char []? http://rsdn.org/forum/mfc/6642249 the Author: VladFein Date: 16.12.16

16

Re: CString in char []

Hello, indee, you wrote: I> As a line CString to convert in char []? It is possible still here so: CString mystr; LPCTSTR pzText; char s [40];//or any other length - the main thing that this line the resultant text int i, n was located;//initialization mystr; n = mystr. GetLength (); pzText = mystr. GetBuffer (); for (i=0; i <n; i ++) s [i] = pzText [i]; s [n] = '\0 ';//a completing NULL-symbol Instead of char s [40]; it is possible to write char *s; s = new char [40];

17

Re: CString in char []

Hello, RussianFellow, you wrote: RF>//initialization mystr; RF> n = mystr. GetLength (); RF> pzText = mystr. GetBuffer (); RF> for (i=0; i <n; i ++) s [i] = pzText [i]; RF> s [n] = '\0 ';//completing NULL-symbol RF> [/ccode] And farewell all  characters outside of seven-bit ASCII. WideCharToMultiByte at least characters from the given code page saves.

18

Re: CString in char []

Hello, V. Zudin, you wrote: SVZ> To begin with it is necessary to be defined, what exactly it is necessary to receive - an array byte, ANSI a line, utf-8 or utf-16? And than, by the way, differ UTF-8 and UTF-16?

19

Re: CString in char []

20

Re: CString in char []

Thanks for the help!  it is solved by update VS to version 15.6.2. In prior version 15.4.  heaps of errors at any mention CString.