简体   繁体   中英

is there something similar to std::quote for multiple characters like ETX/STX pairs

I see there is a function in <iomanip> for quoting a single char out and in a std::string. I search something similar to that for multiple characters. My current use case is to masquerade STX / ETX pairs in/out a string.

Use for std::quote is easy like:

std::string example{ "Hallao" };
std::cout << std::quoted(example, 'a', 'x') << std::endl;

So my wish to see is something like:

std::cout << std::quoted(example, {0x02,0x03}, ...) << std::endl;

Is that already done somewhere or is this to special to be a part of STL?

Unfortunately, so far there isn't. The delim and escape chars are restricted to one character. You can't use multiple chars or string under the current interface.

This unnecessary limitation applies to a lot of components too :( (for example the isalpha family of functions)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM