Search found 80 matches
- April 7th, 2020, 3:41 am
- Forum: Everything
- Topic: Wstring ? international chars ?
- Replies: 27
- Views: 10308
Re: Wstring ? international chars ?
The problem is more when you want to deal with number of true-characters. String.length will not return the number of real chars. And substr won't cut at real-char edges. But Maybe I can handle that. As I mentioned before, the concept of "true character" is kind of iffy in Unicode. It can mean diff...
- April 6th, 2020, 4:38 am
- Forum: Everything
- Topic: Wstring ? international chars ?
- Replies: 27
- Views: 10308
Re: Wstring ? international chars ?
No, std::u32string is (as the name implies) UTF32 and not UTF8. UTF32 has it's own uses but I don't think you don't really need it. By UTF8 string I mean just a regular char array/std::string that uses UTF8 encoding. Here's an example of what concatenating 2 UTF8 strings would look like: std::string...
- April 5th, 2020, 3:28 am
- Forum: Everything
- Topic: Wstring ? international chars ?
- Replies: 27
- Views: 10308
Re: Wstring ? international chars ?
For simple concatenation, you don't need anything complicated, at least with UTF8. Concatenation, finding substrings, and single ASCII char operations all work on a UTF8 strings as they would on dumb ASCII char arrays. Overall I'd recommend you just stick to char/std::string with UTF8 and make sure ...
- April 4th, 2020, 9:05 am
- Forum: Everything
- Topic: Wstring ? international chars ?
- Replies: 27
- Views: 10308
Re: Wstring ? international chars ?
To be clear, UTF16 is (or can be) multi-byte as well. Depending on the letter it may need more than 1 wchar_t to store it. It originated as a fixed-width 16 bit format which can store up to 65536 letters, but soon after they realized that they need more than that and it was upgraded to a variable le...
- April 3rd, 2020, 5:55 pm
- Forum: Everything
- Topic: Wstring ? international chars ?
- Replies: 27
- Views: 10308
Re: Wstring ? international chars ?
There are 2 main approaches with Windows. One is to use what's known as the Unicode charset, which means instead of using a single byte for each char (std::string) you use a 2 byte wchar_t (std::wstring). This is known as UTF16. In Windows terminology whenever you see Unicode mentioned it very likel...
- March 31st, 2020, 10:41 am
- Forum: Everything
- Topic: VC++ 2019 and lib subdir path ?
- Replies: 6
- Views: 3286
Re: VC++ 2019 and lib subdir path ?
Sorry to disappoint you by not being albinopapa. As the docs for SetDllDirectoryA mention, it only affects subsequent calls to LoadLibrary(Ex). Windows will only load DLLs that are located in the same directory as the .exe and in some special system directories. It is possible to load DLLs in anothe...
- March 31st, 2020, 10:36 am
- Forum: Everything
- Topic: std::string::operator+(int) ?
- Replies: 13
- Views: 4804
Re: std::string::operator+(int) ?
Something something evil macros.
Just use a function:
or if you want to be fancy and use perfect forwarding:
Just use a function:
Code: Select all
template <typename T>
std::string tos(const T& t) { return std::to_string(t); }
Code: Select all
template <typename T>
std::string tos(T&& t) { return std::to_string(std::forward<T>(t)); }
- March 19th, 2020, 6:29 am
- Forum: Everything
- Topic: Destroying / clearing a "recursive" vector ?
- Replies: 12
- Views: 5787
Re: Destroying / clearing a "recursive" vector ?
All the AST definitions are in ast.h . The X-Macro declaration is here specifically. You can find an example usage of the X-Macro here for declaring an enum with all the different AST node types. I feel like it's a nice fit for an AST, pretty much every C++ compiler I've seen uses them as well. Don'...
- March 16th, 2020, 5:07 am
- Forum: Everything
- Topic: Auto cast an iterator into its base pointer type ?
- Replies: 25
- Views: 10594
Re: Auto cast an iterator into its base pointer type ?
The point of iterators is to look and feel like a pointer but they aren't always pointers. They "feel" like pointers because they overload the same operators that you would use with a real pointer (e.g. p->x, *p, ++p) but these are just function overloads and an iterator is it's own distinct class. ...
- March 16th, 2020, 4:51 am
- Forum: Everything
- Topic: Destroying / clearing a "recursive" vector ?
- Replies: 12
- Views: 5787
Re: Destroying / clearing a "recursive" vector ?
Project sounds awesome :o Keep us updated on how it goes I was working on a similar thing, a simple statically typed scripting language that I would use in another project of mine (shameless plug: https://github.com/SlidyBat/BatScript) I haven't worked on it for a while but I'm planning on getting b...