Click here to Skip to main content
14,365,441 members

Managed C++/CLI

 
GeneralRe: delete all label in windows form CLI Pin
TheCaptain1013-Jul-15 0:37
memberTheCaptain1013-Jul-15 0:37 
GeneralRe: delete all label in windows form CLI Pin
Richard MacCutchan13-Jul-15 0:48
protectorRichard MacCutchan13-Jul-15 0:48 
Questionremove all label in windows form c++ Pin
TheCaptain1011-Jul-15 19:33
memberTheCaptain1011-Jul-15 19:33 
AnswerRe: remove all label in windows form c++ Pin
Richard MacCutchan11-Jul-15 22:57
protectorRichard MacCutchan11-Jul-15 22:57 
QuestionHow do I convert an .mp3 file to an .sty (style file) - C/C++? Pin
Member 1171281228-Jun-15 22:01
memberMember 1171281228-Jun-15 22:01 
QuestionRe: How do I convert an .mp3 file to an .sty (style file) - C/C++? Pin
Richard MacCutchan28-Jun-15 22:30
protectorRichard MacCutchan28-Jun-15 22:30 
QuestionWideCharToMultiByte vs Encoding::UTF8->GetBytes Pin
John Schroedl17-Jun-15 9:48
professionalJohn Schroedl17-Jun-15 9:48 
AnswerRe: WideCharToMultiByte vs Encoding::UTF8->GetBytes Pin
John Schroedl17-Jun-15 10:29
professionalJohn Schroedl17-Jun-15 10:29 
Update:

Well, my initial experiment proved to me that YES, it's much faster to use WideCharToMultiByte().

The speedup varies by language of text I'm converting of course.

The time to run my tests were reduced by: English: 13%, German: 18%, Japanese: 16%, Chinese: 12%

The gist of my code is now:

String^ str = "...the string to convert...";
			
pin_ptr<const wchar_t> unicode16 = PtrToStringChars(str);

// Perf Note: Surprisingly, using -1 for length is MUCH faster than using a precomputed str->Length+1 
int const cbNeeded = WideCharToMultiByte(CP_UTF8, 0, unicode16, -1, nullptr, 0, nullptr, nullptr);

auto converted = make_unique<MyBuffer>(cbNeeded);

int const cbConverted = WideCharToMultiByte(CP_UTF8, 0, unicode16, -1, converted.get(), cbNeeded, nullptr, nullptr);
			
// ... use converted ...


It was a surprise that passing -1 for the length parameter to WCtoMB resulted in an even faster conversion!

I hope this helps someone out there and I'm still interested in any responses from any devs doing similar work.

John
GeneralRe: WideCharToMultiByte vs Encoding::UTF8->GetBytes Pin
Richard Andrew x6417-Jun-15 16:36
professionalRichard Andrew x6417-Jun-15 16:36 
QuestionConvert From c# - For Report Viewer Report save as PDF format Pin
Paramu197316-Jun-15 21:41
memberParamu197316-Jun-15 21:41 
AnswerRe: Convert From c# - For Report Viewer Report save as PDF format Pin
Richard MacCutchan16-Jun-15 22:54
protectorRichard MacCutchan16-Jun-15 22:54 
AnswerRe: Convert From c# - For Report Viewer Report save as PDF format Pin
John Schroedl17-Jun-15 9:39
professionalJohn Schroedl17-Jun-15 9:39 
GeneralRe: Convert From c# - For Report Viewer Report save as PDF format Pin
Paramu197317-Jun-15 16:07
memberParamu197317-Jun-15 16:07 
QuestionOOP - Error | Unhandled exception at 0x0FD2CCC8 (msvcp110d.dll) Pin
Member 1164129910-Jun-15 3:23
memberMember 1164129910-Jun-15 3:23 
QuestionRe: OOP - Error | Unhandled exception at 0x0FD2CCC8 (msvcp110d.dll) Pin
Richard MacCutchan10-Jun-15 22:32
protectorRichard MacCutchan10-Jun-15 22:32 
QuestionEnabling ListControl pane in MFC (C++) Pin
Yateesh KR12-May-15 23:14
memberYateesh KR12-May-15 23:14 
QuestionRe: Enabling ListControl pane in MFC (C++) Pin
Richard MacCutchan13-May-15 3:55
protectorRichard MacCutchan13-May-15 3:55 
QuestionInheritance tricky question Pin
Amrit Agr12-May-15 10:30
memberAmrit Agr12-May-15 10:30 
AnswerRe: Inheritance tricky question Pin
Sascha Lefèvre12-May-15 12:38
professionalSascha Lefèvre12-May-15 12:38 
GeneralRe: Inheritance tricky question Pin
Amrit Agr13-May-15 8:47
memberAmrit Agr13-May-15 8:47 
AnswerRe: Inheritance tricky question Pin
Sascha Lefèvre13-May-15 10:12
professionalSascha Lefèvre13-May-15 10:12 
Questionenglish language implementation Pin
Member 936602117-Apr-15 4:58
professionalMember 936602117-Apr-15 4:58 
AnswerRe: english language implementation Pin
Member 936602117-Apr-15 5:00
professionalMember 936602117-Apr-15 5:00 
Questionmultiple Pin
memoarfaa16-Apr-15 2:28
membermemoarfaa16-Apr-15 2:28 
GeneralRe: multiple Pin
Richard MacCutchan16-Apr-15 3:20
protectorRichard MacCutchan16-Apr-15 3:20 

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.