This topic demonstrates how to convert various Visual C++ string types into other strings. The strings types that are covered include char *, wchar_t*, _bstr_tCComBSTRCStringbasic_string, and System.String. In all cases, a copy of the string is made when converted to the new type. Any changes made to the new string will not affect the original string, and vice versa.

Converting from char *

Example

Description

This example demonstrates how to convert from a char * to the other string types listed above. A char * string (also known as a C style string) uses a null character to indicate the end of the string. C style strings usually require one byte per character, but can also use two bytes. In the examples below, char * strings are sometimes referred to as multibyte character strings because of the string data that results from converting from Unicode strings. Single byte and multibyte character (MBCS) functions can operate on char * strings.

Code

// convert_from_char.cpp

// compile with: /clr /link comsuppw.lib

 

#include <iostream>

#include <stdlib.h>

#include <string>

 

#include "atlbase.h"

#include "atlstr.h"

#include "comutil.h"

 

using namespace std;

using namespace System;

 

int main()

{

// Create and display a C style string, and then use it

// to create different kinds of strings.

char *orig = "Hello, World!";

cout << orig << " (char *)" << endl;

 

// newsize describes the length of the

// wchar_t string called wcstring in terms of the number

// of wide characters, not the number of bytes.

size_t newsize = strlen(orig) + 1;

 

// The following creates a buffer large enough to contain

// the exact number of characters in the original string

// in the new format. If you want to add more characters

// to the end of the string, increase the value of newsize

// to increase the size of the buffer.

wchar_t * wcstring = new wchar_t[newsize];

 

// Convert char* string to a wchar_t* string.

size_t convertedChars = 0;

mbstowcs_s(&convertedChars, wcstring, newsize, orig, _TRUNCATE);

// Display the result and indicate the type of string that it is.

wcout << wcstring << _T(" (wchar_t *)") << endl;

 

// Convert the C style string to a _bstr_t string.

_bstr_t bstrt(orig);

// Append the type of string to the new string

// and then display the result.

bstrt += " (_bstr_t)";

cout << bstrt << endl;

 

// Convert the C style string to a CComBSTR string.

CComBSTR ccombstr(orig);

if (ccombstr.Append(_T(" (CComBSTR)")) == S_OK)

{

CW2A printstr(ccombstr);

cout << printstr << endl;

}

 

// Convert the C style string to a CstringA and display it.

CStringA cstringa(orig);

cstringa += " (CStringA)";

cout << cstringa << endl;

 

// Convert the C style string to a CStringW and display it.

CStringW cstring(orig);

cstring += " (CStringW)";

// To display a CStringW correctly, use wcout and cast cstring

// to (LPCTSTR).

wcout << (LPCTSTR)cstring << endl;

 

// Convert the C style string to a basic_string and display it.

string basicstring(orig);

basicstring += " (basic_string)";

cout << basicstring << endl;

 

// Convert the C style string to a System::String and display it.

String ^systemstring = gcnew String(orig);

systemstring += " (System::String)";

Console::WriteLine("{0}", systemstring);

delete systemstring;

}

 

Output

Hello, World! (char *)

Hello, World! (wchar_t *)

Hello, World! (_bstr_t)

Hello, World! (CComBSTR)

Hello, World! (CStringA)

Hello, World! (CStringW)

Hello, World! (basic_string)

Hello, World! (System::String)

 

Converting from wchar_t *

Example

Description

This example demonstrates how to convert from a wchar_t * to the other string types listed above. Several string types, including wchar_t *, implement wide character formats. To convert a string between a multibyte and a wide character format, you can use a single function call like mbstowcs_s or a constructor invocation for a class like CStringA.

Code

// convert_from_wchar_t.cpp

// compile with: /clr /link comsuppw.lib

 

#include <iostream>

#include <stdlib.h>

#include <string>

 

#include "atlbase.h"

#include "atlstr.h"

#include "comutil.h"

 

using namespace std;

using namespace System;

 

int main()

{

// Create a string of wide characters, display it, and then

// use this string to create other types of strings.

wchar_t *orig = _T("Hello, World!");

wcout << orig << _T(" (wchar_t *)") << endl;

 

// Convert the wchar_t string to a char* string. Record

//.the length of the original string and add 1 to it to

//.account for the terminating null character.

size_t origsize = wcslen(orig) + 1;

size_t convertedChars = 0;

 

// Use a multibyte string to append the type of string

// to the new string before displaying the result.

char strConcat[] = " (char *)";

size_t strConcatsize = (strlen( strConcat ) + 1)*2;

 

// Allocate two bytes in the multibyte output string for every wide

// character in the input string (including a wide character

// null). Because a multibyte character can be one or two bytes,

// you should allot two bytes for each character. Having extra

// space for the new string is not an error, but having

// insufficient space is a potential security problem.

const size_t newsize = origsize*2;

// The new string will contain a converted copy of the original

// string plus the type of string appended to it.

char *nstring = new char[newsize+strConcatsize];

 

// Put a copy of the converted string into nstring

wcstombs_s(&convertedChars, nstring, newsize, orig, _TRUNCATE);

// append the type of string to the new string.

_mbscat_s((unsigned char*)nstring, newsize+strConcatsize, (unsigned char*)strConcat);

// Display the result.

cout << nstring << endl;

 

// Convert a wchar_t to a _bstr_t string and display it.

_bstr_t bstrt(orig);

bstrt += " (_bstr_t)";

cout << bstrt << endl;

 

// Convert the wchar_t string to a BSTR wide character string

// by using the ATL CComBSTR wrapper class for BSTR strings.

// Then display the result.

 

CComBSTR ccombstr(orig);

if (ccombstr.Append(_T(" (CComBSTR)")) == S_OK)

{

// CW2A converts the string in ccombstr to a multibyte

// string in printstr, used here for display output.

CW2A printstr(ccombstr);

cout << printstr << endl;

// The following line of code is an easier way to

// display wide character strings:

// wcout << (LPCTSTR) ccombstr << endl;

}

 

// Convert a wide wchar_t string to a multibyte CStringA,

// append the type of string to it, and display the result.

CStringA cstringa(orig);

cstringa += " (CStringA)";

cout << cstringa << endl;

 

// Convert a wide character wchar_t string to a wide

// character CStringW string and append the type of string to it

CStringW cstring(orig);

cstring += " (CStringW)";

// To display a CStringW correctly, use wcout and cast cstring

// to (LPCTSTR).

wcout << (LPCTSTR)cstring << endl;

 

// Convert the wide character wchar_t string to a

// basic_string, append the type of string to it, and

// display the result.

wstring basicstring(orig);

basicstring += _T(" (basic_string)");

wcout << basicstring << endl;

 

// Convert a wide character wchar_t string to a

// System::String string, append the type of string to it,

// and display the result.

String ^systemstring = gcnew String(orig);

systemstring += " (System::String)";

Console::WriteLine("{0}", systemstring);

delete systemstring;

}

 

Output

Hello, World! (wchar_t *)

Hello, World! (char *)

Hello, World! (_bstr_t)

Hello, World! (CComBSTR)

Hello, World! (CStringA)

Hello, World! (CStringW)

Hello, World! (basic_string)

Hello, World! (System::String)

 

Converting from _bstr_t

Example

Description

This example demonstrates how to convert from a _bstr_t to the other string types listed above. The _bstr_t object is a way to encapsulate wide character BSTR strings. A BSTR string has a length value and does not use a null character to terminate the string, but the string type you convert to may require a terminating null.

Code

// convert_from_bstr_t.cpp

// compile with: /clr /link comsuppw.lib

 

#include <iostream>

#include <stdlib.h>

#include <string>

 

#include "atlbase.h"

#include "atlstr.h"

#include "comutil.h"

 

using namespace std;

using namespace System;

 

int main()

{

// Create a _bstr_t string, display the result, and indicate the

// type of string that it is.

_bstr_t orig("Hello, World!");

wcout << orig << " (_bstr_t)" << endl;

 

// Convert the wide character _bstr_t string to a C style

// string. To be safe, allocate two bytes for each character

// in the char* string, including the terminating null.

const size_t newsize = (orig.length()+1)*2;

char *nstring = new char[newsize];

 

// Uses the _bstr_t operator (char *) to obtain a null

// terminated string from the _bstr_t object for

// nstring.

strcpy_s(nstring, newsize, (char *)orig);

strcat_s(nstring, newsize, " (char *)");

cout << nstring << endl;

 

// Prepare the type of string to append to the result.

wchar_t strConcat[] = _T(" (wchar_t *)");

size_t strConcatLen = wcslen(strConcat) + 1;

 

// Convert a _bstr_t to a wchar_t* string.

const size_t widesize = orig.length()+ strConcatLen;

wchar_t *wcstring = new wchar_t[newsize];

wcscpy_s(wcstring, widesize, (wchar_t *)orig);

wcscat_s(wcstring, widesize, strConcat);

wcout << wcstring << endl;

 

// Convert a _bstr_t string to a CComBSTR string.

CComBSTR ccombstr((char *)orig);

if (ccombstr.Append(_T(" (CComBSTR)")) == S_OK)

{

CW2A printstr(ccombstr);

cout << printstr << endl;

}

 

// Convert a _bstr_t to a CStringA string.

CStringA cstringa(orig.GetBSTR());

cstringa += " (CStringA)";

cout << cstringa << endl;

 

// Convert a _bstr_t to a CStringW string.

CStringW cstring(orig.GetBSTR());

cstring += " (CStringW)";

// To display a cstring correctly, use wcout and

// "cast" the cstring to (LPCTSTR).

wcout << (LPCTSTR)cstring << endl;

 

// Convert the _bstr_t to a basic_string.

string basicstring((char *)orig);

basicstring += " (basic_string)";

cout << basicstring << endl;

 

// Convert the _bstr_t to a System::String.

String ^systemstring = gcnew String((char *)orig);

systemstring += " (System::String)";

Console::WriteLine("{0}", systemstring);

delete systemstring;

}

 

Output

Hello, World! (_bstr_t)

Hello, World! (char *)

Hello, World! (wchar_t *)

Hello, World! (CComBSTR)

Hello, World! (CStringA)

Hello, World! (CStringW)

Hello, World! (basic_string)

Hello, World! (System::String)

 

Converting from CComBSTR

Example

Description

This example demonstrates how to convert from a CComBSTR to the other string types listed above. Like _bstr_t, a CComBSTR object is a way to encapsulate wide character BSTR strings. A BSTR string has a length value and does not use a null character to terminate the string, but the string type you convert to may require a terminating null.

Code

// convert_from_ccombstr.cpp

// compile with: /clr /link comsuppw.lib

 

#include <iostream>

#include <stdlib.h>

#include <string>

 

#include "atlbase.h"

#include "atlstr.h"

#include "comutil.h"

#include "vcclr.h"

 

using namespace std;

using namespace System;

using namespace System::Runtime::InteropServices;

 

int main()

{

// Create and initialize a BSTR string by using a CComBSTR object.

CComBSTR orig("Hello, World!");

// Convert the BSTR into a multibyte string, display the result,

// and indicate the type of string that it is.

CW2A printstr(orig);

cout << printstr << " (CComBSTR)" << endl;

 

// Convert a wide character CComBSTR string to a

// regular multibyte char* string. Allocate enough space

// in the new string for the largest possible result,

// including space for a terminating null.

const size_t newsize = (orig.Length()+1)*2;

char *nstring = new char[newsize];

 

// Create a string conversion object, copy the result to

// the new char* string, and display the result.

CW2A tmpstr1(orig);

strcpy_s(nstring, newsize, tmpstr1);

cout << nstring << " (char *)" << endl;

 

// Prepare the type of string to append to the result.

wchar_t strConcat[] = _T(" (wchar_t *)");

size_t strConcatLen = wcslen(strConcat) + 1;

 

// Convert a wide character CComBSTR string to a wchar_t*.

// The code first determines the length of the converted string

// plus the length of the appended type of string, then

// prepares the final wchar_t string for display.

const size_t widesize = orig.Length()+ strConcatLen;

wchar_t *wcstring = new wchar_t[widesize];

wcscpy_s(wcstring, widesize, orig);

wcscat_s(wcstring, widesize, strConcat);

 

// Display the result. Unlike CStringW, a wchar_t does not need

// a cast to (LPCTSTR) with wcout.

wcout << wcstring << endl;

 

// Convert a wide character CComBSTR to a wide character _bstr_t,

// append the type of string to it, and display the result.

_bstr_t bstrt(orig);

bstrt += " (_bstr_t)";

cout << bstrt << endl;

 

// Convert a wide character CComBSTR to a multibyte CStringA,

// append the type of string to it, and display the result.

CStringA cstringa(orig);

cstringa += " (CStringA)";

cout << cstringa << endl;

 

// Convert a wide character CComBSTR to a wide character CStringW.

CStringW cstring(orig);

cstring += " (CStringW)";

// To display a cstring correctly, use wcout and cast cstring

// to (LPCTSTR).

wcout << (LPCTSTR)cstring << endl;

 

// Convert a wide character CComBSTR to a wide character

// basic_string.

wstring basicstring(orig);

basicstring += _T(" (basic_string)");

wcout << basicstring << endl;

 

// Convert a wide character CComBSTR to a System::String.

String ^systemstring = gcnew String(orig);

systemstring += " (System::String)";

Console::WriteLine("{0}", systemstring);

delete systemstring;

}

 

Output

Hello, World! (CComBSTR)

Hello, World! (char *)

Hello, World! (wchar_t *)

Hello, World! (_bstr_t)

Hello, World! (CStringA)

Hello, World! (CStringW)

Hello, World! (basic_string)

Hello, World! (System::String)

 

Converting from CString

Example

Description

This example demonstrates how to convert from a CString to the other string types listed above. CString is based on the TCHAR data type, which in turn depends on whether the symbol _UNICODE is defined. If _UNICODE is not defined, TCHAR is defined to be char and CString contains a multibyte character string; if _UNICODE is defined, TCHAR is defined to be wchar_t and CString contains a wide character string.

CStringA is the multibyte string always version of CString, CStringW is the wide character string only version. Neither CStringA nor CStringW use _UNICODE to determine how they should compile. CStringA and CStringW are used in this example to clarify minor differences in buffer size allocation and output handling.

Code

// convert_from_cstring.cpp

// compile with: /clr /link comsuppw.lib

 

#include <iostream>

#include <stdlib.h>

#include <string>

 

#include "atlbase.h"

#include "atlstr.h"

#include "comutil.h"

 

using namespace std;

using namespace System;

 

int main()

{

// Set up a multibyte CStringA string.

CStringA origa("Hello, World!");

cout << origa << " (CStringA)" << endl;

 

// Set up a wide character CStringW string.

CStringW origw("Hello, World!");

wcout << (LPCTSTR)origw << _T(" (CStringW)") << endl;

 

// Convert to a char* string from CStringA string

// and display the result.

const size_t newsizea = (origa.GetLength() + 1);

char *nstringa = new char[newsizea];

strcpy_s(nstringa, newsizea, origa);

cout << nstringa << " (char *)" << endl;

 

// Convert to a char* string from a wide character

// CStringW string. To be safe, we allocate two bytes for each

// character in the original string, including the terminating

// null.

const size_t newsizew = (origw.GetLength() + 1)*2;

char *nstringw = new char[newsizew];

size_t convertedCharsw = 0;

wcstombs_s(&convertedCharsw, nstringw, newsizew, origw, _TRUNCATE );

cout << nstringw << " (char *)" << endl;

 

// Convert to a wchar_t* from CStringA

size_t convertedCharsa = 0;

wchar_t *wcstring = new wchar_t[newsizea];

mbstowcs_s(&convertedCharsa, wcstring, newsizea, origa, _TRUNCATE);

wcout << wcstring << _T(" (wchar_t *)") << endl;

 

// Convert to a wide character wchar_t* string from

// a wide character CStringW string.

wchar_t *n2stringw = new wchar_t[newsizew];

wcscpy_s( n2stringw, newsizew, origw );

wcout << n2stringw << _T(" (wchar_t *)") << endl;

 

// Convert to a wide character _bstr_t string from

// a multibyte CStringA string.

_bstr_t bstrt(origa);

bstrt += _T(" (_bstr_t)");

wcout << bstrt << endl;

 

// Convert to a wide character_bstr_t string from

// a wide character CStringW string.

bstr_t bstrtw(origw);

bstrtw += " (_bstr_t)";

wcout << bstrtw << endl;

 

// Convert to a wide character CComBSTR string from

// a multibyte character CStringA string.

CComBSTR ccombstr(origa);

if (ccombstr.Append(_T(" (CComBSTR)")) == S_OK)

{

// Convert the wide character string to multibyte

// for printing.

CW2A printstr(ccombstr);

cout << printstr << endl;

}

 

// Convert to a wide character CComBSTR string from

// a wide character CStringW string.

CComBSTR ccombstrw(origw);

// Append the type of string to it, and display the result.

 

if (ccombstrw.Append(_T(" (CComBSTR)")) == S_OK)

{

CW2A printstrw(ccombstrw);

wcout << printstrw << endl;

}

 

// Convert a multibyte character CStringA to a

// multibyte version of a basic_string string.

string basicstring(origa);

basicstring += " (basic_string)";

cout << basicstring << endl;

 

// Convert a wide character CStringW to a

// wide character version of a basic_string

// string.

wstring basicstringw(origw);

basicstringw += _T(" (basic_string)");

wcout << basicstringw << endl;

 

// Convert a multibyte character CStringA to a

// System::String.

String ^systemstring = gcnew String(origa);

systemstring += " (System::String)";

Console::WriteLine("{0}", systemstring);

delete systemstring;

 

// Convert a wide character CStringW to a

// System::String.

String ^systemstringw = gcnew String(origw);

systemstringw += " (System::String)";

Console::WriteLine("{0}", systemstringw);

delete systemstringw;

}

 

Output

Hello, World! (CStringA)

Hello, World! (CStringW)

Hello, World! (char *)

Hello, World! (char *)

Hello, World! (wchar_t *)

Hello, World! (wchar_t *)

Hello, World! (_bstr_t)

Hello, World! (_bstr_t)

Hello, World! (CComBSTR)

Hello, World! (CComBSTR)

Hello, World! (basic_string)

Hello, World! (System::String)

 

Converting from basic_string

Example

Description

This example demonstrates how to convert from a basic_string to the other string types listed above.

Code

// convert_from_basic_string.cpp

// compile with: /clr /link comsuppw.lib

 

#include <iostream>

#include <stdlib.h>

#include <string>

 

#include "atlbase.h"

#include "atlstr.h"

#include "comutil.h"

 

using namespace std;

using namespace System;

 

int main()

{

// Set up a basic_string string.

string orig("Hello, World!");

cout << orig << " (basic_string)" << endl;

 

// Convert a wide char basic_string string to a multibyte char*

// string. To be safe, we allocate two bytes for each character

// in the original string, including the terminating null.

const size_t newsize = (strlen(orig.c_str()) + 1)*2;

char *nstring = new char[newsize];

strcpy_s(nstring, newsize, orig.c_str());

cout << nstring << " (char *)" << endl;

 

// Convert a basic_string string to a wide character

// wchar_t* string. You must first convert to a char*

// for this to work.

const size_t newsizew = strlen(orig.c_str()) + 1;

size_t convertedChars = 0;

wchar_t *wcstring = new wchar_t[newsizew];

mbstowcs_s(&convertedChars, wcstring, newsizew, orig.c_str(), _TRUNCATE);

wcout << wcstring << _T(" (wchar_t *)") << endl;

 

// Convert a basic_string string to a wide character

// _bstr_t string.

_bstr_t bstrt(orig.c_str());

bstrt += _T(" (_bstr_t)");

wcout << bstrt << endl;

 

// Convert a basic_string string to a wide character

// CComBSTR string.

CComBSTR ccombstr(orig.c_str());

if (ccombstr.Append(_T(" (CComBSTR)")) == S_OK)

{

// Make a multibyte version of the CComBSTR string

// and display the result.

CW2A printstr(ccombstr);

cout << printstr << endl;

}

 

// Convert a basic_string string into a multibyte

// CStringA string.

CStringA cstring(orig.c_str());

cstring += " (CStringA)";

cout << cstring << endl;

 

// Convert a basic_string string into a wide

// character CStringW string.

CStringW cstringw(orig.c_str());

cstringw += _T(" (CStringW)");

wcout << (LPCTSTR)cstringw << endl;

 

// Convert a basic_string string to a System::String

String ^systemstring = gcnew String(orig.c_str());

systemstring += " (System::String)";

Console::WriteLine("{0}", systemstring);

delete systemstring;

}

 

Output

Hello, World! (basic_string)

Hello, World! (char *)

Hello, World! (wchar_t *)

Hello, World! (_bstr_t)

Hello, World! (CComBSTR)

Hello, World! (CStringA)

Hello, World! (CStringW)

Hello, World! (System::String)

 

Converting from System::String

Example

Description

This example demonstrates how to convert from a wide character (Unicode) System::String to the other string types listed above.

Code

// convert_from_system_string.cpp

// compile with: /clr /link comsuppw.lib

 

#include <iostream>

#include <stdlib.h>

#include <string>

 

#include "atlbase.h"

#include "atlstr.h"

#include "comutil.h"

#include "vcclr.h"

 

using namespace std;

using namespace System;

using namespace System::Runtime::InteropServices;

 

int main()

{

// Set up a System::String and display the result.

String ^orig = gcnew String("Hello, World!");

Console::WriteLine("{0} (System::String)", orig);

 

// Obtain a pointer to the System::String in order to

// first lock memory into place, so that the

// Garbage Collector (GC) cannot move that object

// while we call native functions.

pin_ptr<const wchar_t> wch = PtrToStringChars(orig);

 

// Make a copy of the system string as a multibyte

// char* string. Allocate two bytes in the multibyte

// output string for every wide character in the input

// string, including space for a terminating null.

size_t origsize = wcslen(wch) + 1;

const size_t newsize = origsize*2;

size_t convertedChars = 0;

char *nstring = new char[newsize];

wcstombs_s(&convertedChars, nstring, newsize, wch, _TRUNCATE);

cout << nstring << " (char *)" << endl;

 

// Convert a wide character system string to a

// wide character wchar_t* string.

const size_t newsizew = origsize;

wchar_t *wcstring = new wchar_t[newsizew];

wcscpy_s(wcstring, newsizew, wch);

wcout << wcstring << _T(" (wchar_t *)") << endl;

 

// Convert a wide character system string to a

// wide character _bstr_t string.

_bstr_t bstrt(wch);

bstrt += " (_bstr_t)";

cout << bstrt << endl;

 

// Convert a wide character system string

// to a wide character CComBSTR string.

CComBSTR ccombstr(wch);

if (ccombstr.Append(_T(" (CComBSTR)")) == S_OK)

{

// Make a multibyte copy of the CComBSTR string

// and display the result.

CW2A printstr(ccombstr);

cout << printstr << endl;

}

 

// Convert a wide character System::String to

// a multibyte CStringA string.

CStringA cstring(wch);

cstring += " (CStringA)";

cout << cstring << endl;

 

// Convert a wide character System::String to

// a wide character CStringW string.

CStringW cstringw(wch);

cstringw += " (CStringW)";

wcout << (LPCTSTR)cstringw << endl;

 

// Convert a wide character System::String to

// a wide character basic_string.

wstring basicstring(wch);

basicstring += _T(" (basic_string)");

wcout << basicstring << endl;

 

delete orig;

}

 

Output

Hello, World! (System::String)

Hello, World! (char *)

Hello, World! (wchar_t *)

Hello, World! (_bstr_t)

Hello, World! (CComBSTR)

Hello, World! (CStringA)

Hello, World! (CStringW)

Hello, World! (basic_string)

 

From: https://msdn.microsoft.com/en-us/library/ms235631(v=vs.140).aspx

How to: Convert Between Various String Types的更多相关文章

  1. itoa : Convert integer to string

      Quote from:  http://www.cplusplus.com/reference/cstdlib/itoa/   function   Required header : <s ...

  2. ToString()、Convert.ToString()、(string)、as string 的区别

    通常 object 到 string 有四种方式(假设有object obj):obj.ToString().Convert.ToString().(string)obj.obj as string. ...

  3. how convert large HEX string to binary array ?

    how convert large HEX string to binary I have a string with 14 characters . This is a hex represanta ...

  4. How to convert a std::string to const char* or char*?

    How to convert a std::string to const char* or char*? 1. If you just want to pass a std::string to a ...

  5. convert URL Query String to Object All In One

    convert URL Query String to Object All In One URL / query string / paramas query string to object le ...

  6. convert number or string to ASCII in js

    convert number or string to ASCII in js ASCII dictionary generator // const dict = `abcdefghijklmnop ...

  7. Convert java.lang.String to oracle.jbo.domain.Date

    https://www.techartifact.com/blogs/2013/09/converting-java-lang-string-to-oracle-jbo-domain-date.htm ...

  8. java-org.springframework.core.convert.ConversionFailedException- 前端传string解析date异常

    关于SpringMVC前台日期作为实体类对象参数类型转换错误解决 异常信息: Field error in object 'tblHouse' on field 'houseTime': reject ...

  9. Hex string convert to Binary String and Vise-Versa(16进制和2进制字符串的相互转换)

    这个转换在我们日常的编码中还是很有机会遇到的,这里贴出来和大家分享探讨. void pu_hex_to_binary(std::string strHex, std::string &strB ...

随机推荐

  1. 微信:JSSDK开发

    根据微信开发文档步骤如下: 1.先登录微信公众平台进入“公众号设置”的“功能设置”里填写“JS接口安全域名”. JS接口安全域名设置 mi.com(前面不用带www/http,域名必须备案过) 2.引 ...

  2. 局部变量&&malloc函数&&生命周期的一些见解

    最近在温习指针的部分时发现了一个有趣的问题,先看以下程序: //1.c #include<stdio.h> int* fun() { int t = 567; return &t; ...

  3. [MySQL] 号称永久解决了复制延迟问题的并行复制,MySQL5.7

    一.缘由: 某天看到主从复制延时的告警有点频繁,就想着是不是彻底可以解决一下. 一般主从复制,有三个线程参与,都是单线程:Binlog Dump(主) ----->IO Thread (从) - ...

  4. MVC4中 访问webservice 出现无法找到资源的错误

    出现这个情况,是mvc将webservice.asmx解析成了控制器,下面先将这个控制器忽略 继续访问出现这样的错误: 下面修改配置文件 访问成功

  5. js产生随机数函数

    函数: //产生随机数函数 function RndNum(n){ var rnd=""; for(var i=0;i<n;i++) rnd+=Math.floor(Math ...

  6. 燕十八MySQL优化学习笔记

    观察 show status; 里面的这三个参数;Queries Threads_connected Threads_running判断周期性变化 -------------------------- ...

  7. asp.net mvc多条件+分页查询解决方案

    开发环境vs2010 css:bootstrap js:jquery bootstrap paginator 原先只是想做个mvc的分页,但是一般的数据展现都需要检索条件,而且是多个条件,所以就变成了 ...

  8. mount不是很熟悉 转载文章了解下 转自http://forum.ubuntu.org.cn/viewtopic.php?f=120&t=257333

    纯粹针对刚刚解封开包的新新手,老鸟们请自觉绕行,否则浪费你的时间你非要逼我做谋杀犯可不光我的事你还没地方说理去.如果你正好是个崭新的新手,就耐心的花点时间看看吧,至少大概看看,不要在一个陌生又黑暗的到 ...

  9. 如何将Debug文件夹下的资源打包成一个EXE文件直接执行

    前言:前段时间写了个小程序,想分享给好友看看,可所以资源都放在Debug文件夹下,整个文件夹发给人家这也太……,为了显得稍微专业一点,想把它们打包一个EXE文件执行,因为我见到到这样的程序,直接一个E ...

  10. 阐述ArrayList、Vector、LinkedList的存储性能和特性?(转)

    ArrayList 和Vector他们底层的实现都是一样的,都是使用数组方式存储数据,此数组元素数大于实际存储的数据以便增加和插入元素,它们都允许直接按序号索引元素,但是插入元素要涉及数组元素移动等内 ...