Click here to Skip to main content
15,911,711 members
Home / Discussions / Managed C++/CLI
   

Managed C++/CLI

 
GeneralRe: Reparing Access database Pin
palbano2-Aug-04 6:28
palbano2-Aug-04 6:28 
GeneralC++ vs Managed Pin
---Mark---30-Jul-04 10:39
---Mark---30-Jul-04 10:39 
GeneralRe: C++ vs Managed Pin
palbano31-Jul-04 19:02
palbano31-Jul-04 19:02 
Generalassign mfc handle to dotnet form Pin
luke0530-Jul-04 1:36
luke0530-Jul-04 1:36 
GeneralUpdating multiple treeviews Pin
Sam Barham29-Jul-04 13:45
Sam Barham29-Jul-04 13:45 
GeneralConverting a managed .NET System::String to an unmanaged, UTF-8 encoded, null-terminated char array Pin
jerrycainjr29-Jul-04 8:30
jerrycainjr29-Jul-04 8:30 
GeneralRe: Converting a managed .NET System::String to an unmanaged, UTF-8 encoded, null-terminated char array Pin
palbano29-Jul-04 11:00
palbano29-Jul-04 11:00 
GeneralRe: Converting a managed .NET System::String to an unmanaged, UTF-8 encoded, null-terminated char array Pin
jerrycainjr30-Jul-04 10:07
jerrycainjr30-Jul-04 10:07 
This is the best solution I ultimately came up with. It's not all that satisfying, because I'd think there'd be something that allowed me to do the equivalent of strcpy from a Byte[] or a char[], but if there is, then I"m unaware of it.

// Populates the specified buffer with the
// UTF-8 encoded, null-terminated C-string
// logically equivalent to the specified converts
// from a Unicode .NET string

void Convert(String *unicodeText, char buffer[], int buflen)
{
Convert(unicodeText, char buffer[], int buflen, Encoding::UTF8);
} // wrapper to a more generic function

void Convert(String *unicodeText, char buffer[], int buflen,
Encoding *encoding)
{
Byte bytes[] = encoding->GetBytes(unicodeText);
if (bytes->Count> buflen - 1) throw new Exception();
for (int i = 0; i < bytes->Count; i++)
buffer[i] = bytes[i]; // char is assignable to System::Byte
buffer[bytes->Count] = '\0';
}

A UTF-8 representation of "hello" is just like the traditional ASCII representation, since all five characters are faithfully mapped to numbers less than 128: UTF-8 and ASCII are the same. But German strings containing
umlauts and eszets, such as "FluBen" (where we'll pretend that the u is a really an umlauted u and the B is the double ess aka eszet) require more bytes. "FluBen" would marhal to 8 bytes, because the center two characters have UTF8 mappings that are two bytes wide.

If anyone knows of a more official solution to this, then I'd be delighted to hear of it. Thanks for your time.

Jerry
GeneralQuestion about DLL imports - Fast Pin
Stanimir_Stoyanov24-Jul-04 20:20
Stanimir_Stoyanov24-Jul-04 20:20 
GeneralCOM Interop Question Pin
ursus zeta23-Jul-04 12:26
ursus zeta23-Jul-04 12:26 
GeneralFurther Adventures Pin
ursus zeta4-Aug-04 10:37
ursus zeta4-Aug-04 10:37 
GeneralPossible Memory Leak issues Pin
Anonymous23-Jul-04 5:19
Anonymous23-Jul-04 5:19 
GeneralFast question Pin
Oriocat22-Jul-04 10:50
Oriocat22-Jul-04 10:50 
GeneralRe: Fast question Pin
Daniel Turini22-Jul-04 10:57
Daniel Turini22-Jul-04 10:57 
Generalneed doctor to check this pice of code Pin
Oriocat22-Jul-04 9:58
Oriocat22-Jul-04 9:58 
GeneralProblem... Pin
Pazzuzu22-Jul-04 5:13
Pazzuzu22-Jul-04 5:13 
GeneralRe: Problem... Pin
palbano25-Jul-04 18:05
palbano25-Jul-04 18:05 
GeneralConverting ... Pin
User 91483322-Jul-04 3:59
User 91483322-Jul-04 3:59 
GeneralRe: Converting ... Pin
palbano25-Jul-04 18:04
palbano25-Jul-04 18:04 
GeneralWebService without ASP and IIS Pin
MyPaq22-Jul-04 2:08
MyPaq22-Jul-04 2:08 
GeneralGoing mad with this Pin
Pazzuzu21-Jul-04 6:11
Pazzuzu21-Jul-04 6:11 
GeneralRe: Going mad with this Pin
palbano21-Jul-04 17:28
palbano21-Jul-04 17:28 
GeneralRe: Going mad with this Pin
Pazzuzu22-Jul-04 0:07
Pazzuzu22-Jul-04 0:07 
QuestionHow to convert....... Pin
Pazzuzu21-Jul-04 4:09
Pazzuzu21-Jul-04 4:09 
GeneralVritual functions wapping Pin
Mostafa Mohamed20-Jul-04 2:12
Mostafa Mohamed20-Jul-04 2:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.