Tolower / toupper for strings?


#1

I realize this could be added in c++ but I’m wondering of there are any free functions or string methods to convert string case?

Thanks.


#2

It’s all already there, just bind a function to it.


#3

Thanks, aggsol.

Heh, that could be said for anything. It’s already there just add it.

Trivial as it is, I wanted to make sure I was not injecting a function into the engine where one already existed.


#4

ChaiScript is kept bare on purpose (@lefticus may correct me here if I am wrong) and such functions as tolower() are easily added when required. Maybe some kind of extension module would be a great project if other people require something like a stdlib. (I won’t need it as I like to implement only the ones I need)


#5

Yeah, @aggsol, it makes sense to keep it lean.


#6

Especially if you think about providing some kind of standard lib functions for string (split etc.) then the sensible thing to do is to support UTF-8. But having a working tolower/toupper for UTF-8 really opens up a can of worms I rather not touch.


#7

Yeah, as far as I can tell std::string is not compatible with utf-8.

A standard replacement is needed. Separating size in bytes from characters and iterating in code points. UTF-8 cannot be randomly accessed (O(1)) as well without some other memory representation.

Bag of worms.


#8

There’s been discussion about allowing user replacement of the internal std::string for other (ie std::u16string) implementations.

But the goal has been that the ChaiScript string type would “be the expected thing.”


String manipulation