Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

string - Why is the following C++ code printing only the first character? -


i trying convert char string wchar string.

in more detail: trying convert char[] wchar[] first , append " 1" string , print it.

char src[256] = "c:\\user";  wchar_t temp_src[256]; mbtowc(temp_src, src, 256);  wchar_t path[256];  stringcbprintf(path, 256, _t("%s 1"), temp_src); wcout << path; 

but prints c

is right way convert char wchar? have come know of way since. i'd know why above code works way does?

mbtowc converts single character. did mean use mbstowcs?

typically call function twice; first obtain required buffer size, , second convert it:

#include <cstdlib> // mbstowcs  const char* mbs = "c:\\user"; size_t requiredsize = ::mbstowcs(null, mbs, 0); wchar_t* wcs = new wchar_t[requiredsize + 1]; if(::mbstowcs(wcs, mbs, requiredsize + 1) != (size_t)(-1)) {     // what's needed wcs string } delete[] wcs; 

if rather use mbstowcs_s (because of deprecation warnings), this:

#include <cstdlib> // mbstowcs_s  const char* mbs = "c:\\user"; size_t requiredsize = 0; ::mbstowcs_s(&requiredsize, null, 0, mbs, 0); wchar_t* wcs = new wchar_t[requiredsize + 1]; ::mbstowcs_s(&requiredsize, wcs, requiredsize + 1, mbs, requiredsize); if(requiredsize != 0) {     // what's needed wcs string } delete[] wcs; 

make sure take care of locale issues via setlocale() or using versions of mbstowcs() (such mbstowcs_l() or mbstowcs_s_l()) takes locale argument.


Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -