Search found 51 matches

by Slidy
April 9th, 2020, 3:26 pm
Forum: Everything
Topic: Wstring ? international chars ?
Replies: 21
Views: 123

Re: Wstring ? international chars ?

Game looks sweet :O
You should definitely post a demo once it's playable

Your scripting language has some interesting syntactic choices with everything being function-like, kind of reminds me of Lisp.
by Slidy
April 7th, 2020, 3:41 am
Forum: Everything
Topic: Wstring ? international chars ?
Replies: 21
Views: 123

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...
by Slidy
April 6th, 2020, 4:38 am
Forum: Everything
Topic: Wstring ? international chars ?
Replies: 21
Views: 123

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...
by Slidy
April 5th, 2020, 3:28 am
Forum: Everything
Topic: Wstring ? international chars ?
Replies: 21
Views: 123

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 ...
by Slidy
April 4th, 2020, 9:05 am
Forum: Everything
Topic: Wstring ? international chars ?
Replies: 21
Views: 123

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...
by Slidy
April 3rd, 2020, 5:55 pm
Forum: Everything
Topic: Wstring ? international chars ?
Replies: 21
Views: 123

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...
by Slidy
March 31st, 2020, 10:41 am
Forum: Everything
Topic: VC++ 2019 and lib subdir path ?
Replies: 2
Views: 29

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...
by Slidy
March 31st, 2020, 10:36 am
Forum: Everything
Topic: std::string::operator+(int) ?
Replies: 13
Views: 59

Re: std::string::operator+(int) ?

Something something evil macros.

Just use a function:

Code: Select all

template <typename T>
std::string tos(const T& t) { return std::to_string(t); }
or if you want to be fancy and use perfect forwarding:

Code: Select all

template <typename T>
std::string tos(T&& t) { return std::to_string(std::forward<T>(t)); }
by Slidy
March 19th, 2020, 6:29 am
Forum: Everything
Topic: Destroying / clearing a "recursive" vector ?
Replies: 12
Views: 403

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'...
by Slidy
March 16th, 2020, 5:07 am
Forum: Everything
Topic: Auto cast an iterator into its base pointer type ?
Replies: 25
Views: 467

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. ...