Alex Rivera | Logout

Get size of a std::string's string in bytes

Asked 2011-06-04T08:00:32.813
26

I would like to get the bytes a std::string's string occupies in memory, not the number of characters. The string contains a multibyte string. Would std::string::size() do this for me?

EDIT: Also, does size() also include the terminating NULL?

Edit
Report

1 Answer

2

Yes, size() will give you the number of char in the string. One character in multibyte encoding take up multiple char.

answered 2011-06-04T08:04:23.273

Your Answer