On 2012-04-09, Roy Smith <r...@panix.com> wrote: > In article <4f82d3e2$1$fuzhry+tra$mr2...@news.patriot.net>, > Shmuel (Seymour J.) Metz <spamt...@library.lspace.org.invalid> wrote: > >> >Null terminated strings have simplified all kids of text >> >manipulation, lexical scanning, and data storage/communication >> >code resulting in immeasurable savings over the years. >> >> Yeah, especially code that needs to deal with lengths and nulls. It's >> great for buffer overruns too. > > I once worked on a C++ project that used a string class which kept a > length count, but also allocated one extra byte and stuck a null at the > end of every string.
Me too! I worked on numerous C++ projects with such a string template class. It was usually called std::basic_string and came from this header called: #include <string> which also instantiated it into two flavors under two nicknames: std::basic_string<char> being introduced as std::string, and std::basic_string<wchar_t> as std::wstring. This class had a c_str() function which retrieved a null-terminated string and so most implementations just stored the data that way, but some of the versions of that class cached the length of the string to avoid doing a strlen or wcslen operation on the data. -- http://mail.python.org/mailman/listinfo/python-list