Skip to main content
Stack Overflow
  1. About
  2. For Teams

Return to Question

C++ is not a platform; C++11 is in the tags
Source Link
Enlico
  • 30.3k
  • 10
  • 73
  • 166

My platform is a Mac and C++11 (or above). I'm a C++ beginner and working on a personal project which processes Chinese and English. UTF-8 is the preferred encoding for this project.

I read some posts on Stack Overflow, and many of them suggest using std::string when dealing with UTF-8 and avoid wchar_t as there's no char8_t right now for UTF-8.

However, none of them talk about how to properly deal with functions like str[i], std::string::size(), std::string::find_first_of() or std::regex as these function usually returns unexpected results when facing UTF-8.

Should I go ahead with std::string or switch to std::wstring? If I should stay with std::string, what's the best practice for one to handle the above problems?

My platform is a Mac and C++11 (or above). I'm a C++ beginner and working on a personal project which processes Chinese and English. UTF-8 is the preferred encoding for this project.

I read some posts on Stack Overflow, and many of them suggest using std::string when dealing with UTF-8 and avoid wchar_t as there's no char8_t right now for UTF-8.

However, none of them talk about how to properly deal with functions like str[i], std::string::size(), std::string::find_first_of() or std::regex as these function usually returns unexpected results when facing UTF-8.

Should I go ahead with std::string or switch to std::wstring? If I should stay with std::string, what's the best practice for one to handle the above problems?

My platform is a Mac. I'm a C++ beginner and working on a personal project which processes Chinese and English. UTF-8 is the preferred encoding for this project.

I read some posts on Stack Overflow, and many of them suggest using std::string when dealing with UTF-8 and avoid wchar_t as there's no char8_t right now for UTF-8.

However, none of them talk about how to properly deal with functions like str[i], std::string::size(), std::string::find_first_of() or std::regex as these function usually returns unexpected results when facing UTF-8.

Should I go ahead with std::string or switch to std::wstring? If I should stay with std::string, what's the best practice for one to handle the above problems?

Active reading [<https://en.wikipedia.org/wiki/C%2B%2B11> <http://stackoverflow.com/legal/trademark-guidance> (the last section)]. Removed meta information (this belongs in comments).
Source Link
Peter Mortensen
  • 31.3k
  • 22
  • 110
  • 134

How todo I properly use std::string on utfUTF-8 in C++?

My platform is a Mac and c++11C++11 (or above). I'm a C++ beginner and working on a personal project which processes Chinese and English. utf-8UTF-8 is the preferred encoding for this project.

I read some posts on stackoverflowStack Overflow, and many of them suggest using std::string when dealing with utf-8UTF-8 and avoid wchar_t as there's no char8_t right now for utf-8UTF-8.

However, none of them talk about how to properly deal witwith functions like str[i], std::string::size(), std::string::find_first_of() or std::regex as these function usually returns unexpected results when facing utf-8UTF-8.

Should I go ahead with std::string or switch to std::wstring? If I should stay with std::string, what's the best practice for one to handle the above problems?

Thanks in advance.

How to properly use std::string on utf-8 in C++?

My platform is a Mac and c++11(or above). I'm a C++ beginner and working on a personal project which processes Chinese and English. utf-8 is the preferred encoding for this project.

I read some posts on stackoverflow, and many of them suggest using std::string when dealing with utf-8 and avoid wchar_t as there's no char8_t right now for utf-8.

However, none of them talk about how to properly deal wit functions like str[i], std::string::size(), std::string::find_first_of() or std::regex as these function usually returns unexpected results when facing utf-8.

Should I go ahead with std::string or switch to std::wstring? If I should stay with std::string, what's the best practice for one to handle the above problems?

Thanks in advance.

How do I properly use std::string on UTF-8 in C++?

My platform is a Mac and C++11 (or above). I'm a C++ beginner and working on a personal project which processes Chinese and English. UTF-8 is the preferred encoding for this project.

I read some posts on Stack Overflow, and many of them suggest using std::string when dealing with UTF-8 and avoid wchar_t as there's no char8_t right now for UTF-8.

However, none of them talk about how to properly deal with functions like str[i], std::string::size(), std::string::find_first_of() or std::regex as these function usually returns unexpected results when facing UTF-8.

Should I go ahead with std::string or switch to std::wstring? If I should stay with std::string, what's the best practice for one to handle the above problems?

more tags
Link
Vadim Kotov
  • 8.3k
  • 8
  • 51
  • 63
Source Link
Saddle Point
  • 3.3k
  • 4
  • 28
  • 40
Loading
lang-cpp

AltStyle によって変換されたページ (->オリジナル) /