Re: How to print unicode characters (no library)?

2021-12-28 Thread rempas via Digitalmars-d-learn
On Tuesday, 28 December 2021 at 14:53:57 UTC, rempas wrote: On Tuesday, 28 December 2021 at 12:56:11 UTC, Adam D Ruppe wrote: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html and that's not quite full either. it really is a mess from hell Still less complicated and organized

Re: How to print unicode characters (no library)?

2021-12-28 Thread rempas via Digitalmars-d-learn
On Tuesday, 28 December 2021 at 13:04:26 UTC, Adam D Ruppe wrote: What is your library? You might be able to just use my terminal.d too My library will be "libd" it will be like "libc" but better and cooler! And it will be native to D! And of course it will not depend on "libc" and it

Re: How to print unicode characters (no library)?

2021-12-28 Thread rempas via Digitalmars-d-learn
On Tuesday, 28 December 2021 at 12:56:11 UTC, Adam D Ruppe wrote: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html and that's not quite full either. it really is a mess from hell Still less complicated and organized than my life...

Re: How to print unicode characters (no library)?

2021-12-28 Thread Adam D Ruppe via Digitalmars-d-learn
On Tuesday, 28 December 2021 at 06:51:52 UTC, rempas wrote: That's pretty nice. In this case is even better because at least for now, I will not work on Windows by myself because making the library work on Linux is a bit of a challenge itself. What is your library? You might be able to just

Re: How to print unicode characters (no library)?

2021-12-28 Thread Adam D Ruppe via Digitalmars-d-learn
On Tuesday, 28 December 2021 at 07:03:25 UTC, rempas wrote: I already knew about some of this "escape codes" but I full list of them will come in handy ;) https://invisible-island.net/xterm/ctlseqs/ctlseqs.html and that's not quite full either. it really is a mess from hell

Re: How to print unicode characters (no library)?

2021-12-28 Thread Adam D Ruppe via Digitalmars-d-learn
On Tuesday, 28 December 2021 at 06:46:57 UTC, ag0aep6g wrote: It's actually just the first byte that tells you how many are in the sequence. The continuation bytes don't have redundancies for that. Right, but they do have that high bit set and next bit clear so you can tell you're in the

Re: How to print unicode characters (no library)?

2021-12-28 Thread Patrick Schluter via Digitalmars-d-learn
On Monday, 27 December 2021 at 07:12:24 UTC, rempas wrote: I don't understand that. Based on your calculations, the results should have been different. Also how are the numbers fixed? Like you said the amount of bytes of each encoding is not always standard for every character. Even if they

Re: How to print unicode characters (no library)?

2021-12-27 Thread rempas via Digitalmars-d-learn
On Monday, 27 December 2021 at 21:38:03 UTC, Era Scarecrow wrote: Well to add functionality with say ANSI you entered an escape code and then stuff like offset, color, effect, etc. UTF-8 automatically has escape codes being anything 128 or over, so as long as the terminal understand it, it

Re: How to print unicode characters (no library)?

2021-12-27 Thread rempas via Digitalmars-d-learn
On Monday, 27 December 2021 at 14:47:51 UTC, Kagamin wrote: https://utf8everywhere.org/ - this is an advise from a windows programmer, I use it too. Windows allocates a per thread buffer and when you call, say, WriteConsoleA, it first transcodes the string to UTF-16 in the buffer and calls

Re: How to print unicode characters (no library)?

2021-12-27 Thread rempas via Digitalmars-d-learn
On Monday, 27 December 2021 at 14:30:55 UTC, Adam D Ruppe wrote: Most unix things do utf-8 more often than not, but technically you are supposed to check the locale and change the terminal settings to do it right. Cool! I mean, I don't plan on supporting legacy systems so I think we're fine

Re: How to print unicode characters (no library)?

2021-12-27 Thread ag0aep6g via Digitalmars-d-learn
On 27.12.21 15:23, Adam D Ruppe wrote: Let's look at: "Hello \n"; [...] Finally, there's "string", which is utf-8, meaning each element is 8 bits, but again, there is a buffer you need to build up to get the code points you feed into that VM. [...] H, e, l, l, o, , MORE elements>, , ,

Re: How to print unicode characters (no library)?

2021-12-27 Thread rempas via Digitalmars-d-learn
On Monday, 27 December 2021 at 14:23:37 UTC, Adam D Ruppe wrote: [...] After reading the whole things, I said it and I'll say it again! You guys must get paid for your support I also helped a guy in another forum yesterday writing a very big reply and tbh it felt great :P (or of

Re: How to print unicode characters (no library)?

2021-12-27 Thread Era Scarecrow via Digitalmars-d-learn
On Monday, 27 December 2021 at 07:12:24 UTC, rempas wrote: On Sunday, 26 December 2021 at 21:22:42 UTC, Adam Ruppe wrote: write just transfers a sequence of bytes. It doesn't know nor care what they represent - that's for the receiving end to figure out. Oh, so it was as I expected :P

Re: How to print unicode characters (no library)?

2021-12-27 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Dec 27, 2021 at 04:40:19PM +, Adam D Ruppe via Digitalmars-d-learn wrote: > On Monday, 27 December 2021 at 15:26:16 UTC, H. S. Teoh wrote: > > A lot of modern Linux applications don't even work properly under > > anything non-UTF-8 > > yeah, you're supposed to check the locale but

Re: How to print unicode characters (no library)?

2021-12-27 Thread Adam D Ruppe via Digitalmars-d-learn
On Monday, 27 December 2021 at 15:26:16 UTC, H. S. Teoh wrote: A lot of modern Linux applications don't even work properly under anything non-UTF-8 yeah, you're supposed to check the locale but since so many people just assume that's becoming the new de facto reality just like how people

Re: How to print unicode characters (no library)?

2021-12-27 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Dec 27, 2021 at 02:30:55PM +, Adam D Ruppe via Digitalmars-d-learn wrote: > On Monday, 27 December 2021 at 11:21:54 UTC, rempas wrote: > > So should I just use UTF-8 only for Linux? > > Most unix things do utf-8 more often than not, but technically you are > supposed to check the

Re: How to print unicode characters (no library)?

2021-12-27 Thread Kagamin via Digitalmars-d-learn
On Monday, 27 December 2021 at 11:21:54 UTC, rempas wrote: So should I just use UTF-8 only for Linux? What about other operating systems? I suppose Unix-based OSs (maybe MacOS as well if I'm lucky) work the same as well. But what about Windows? Unfortunately I have to support this OS too with

Re: How to print unicode characters (no library)?

2021-12-27 Thread Adam D Ruppe via Digitalmars-d-learn
On Monday, 27 December 2021 at 11:21:54 UTC, rempas wrote: So should I just use UTF-8 only for Linux? Most unix things do utf-8 more often than not, but technically you are supposed to check the locale and change the terminal settings to do it right. But what about Windows? You should

Re: How to print unicode characters (no library)?

2021-12-27 Thread Adam D Ruppe via Digitalmars-d-learn
On Monday, 27 December 2021 at 07:12:24 UTC, rempas wrote: Oh yeah. About that, I wasn't given a demonstration of how it works so I forgot about it. I saw that in Unicode you can combine some code points to get different results but I never saw how that happens in practice. The emoji is one

Re: How to print unicode characters (no library)?

2021-12-27 Thread rempas via Digitalmars-d-learn
On Monday, 27 December 2021 at 09:29:38 UTC, Kagamin wrote: D strings are plain arrays without any text-specific logic, the element is called code unit, which has a fixed size, and the array length specifies how many elements are in the array. This model is most adequate for memory

Re: How to print unicode characters (no library)?

2021-12-27 Thread Kagamin via Digitalmars-d-learn
On Monday, 27 December 2021 at 07:29:05 UTC, rempas wrote: How can you do that? I'm trying to print the codes for them but it doesn't work. Or you cannot choose to have this behavior and there are only some terminals that support this? Try it on https://en.wikipedia.org/wiki/Teletype_Model_33

Re: How to print unicode characters (no library)?

2021-12-27 Thread Kagamin via Digitalmars-d-learn
D strings are plain arrays without any text-specific logic, the element is called code unit, which has a fixed size, and the array length specifies how many elements are in the array. This model is most adequate for memory correctness, i.e. it shows what takes how much memory and where it will

Re: How to print unicode characters (no library)?

2021-12-26 Thread rempas via Digitalmars-d-learn
On Sunday, 26 December 2021 at 23:57:47 UTC, H. S. Teoh wrote: In some Unix terminals, backspace + '_' causes a character to be underlined. So it's really a mini VM, not just pure data. So yeah, the good ole ASCII days never happened. :-D T How can you do that? I'm trying to print the codes

Re: How to print unicode characters (no library)?

2021-12-26 Thread rempas via Digitalmars-d-learn
On Sunday, 26 December 2021 at 21:22:42 UTC, Adam Ruppe wrote: write just transfers a sequence of bytes. It doesn't know nor care what they represent - that's for the receiving end to figure out. Oh, so it was as I expected :P You are mistaken. There's several exceptions, utf-16 can come

Re: How to print unicode characters (no library)?

2021-12-26 Thread H. S. Teoh via Digitalmars-d-learn
On Sun, Dec 26, 2021 at 11:45:25PM +, max haughton via Digitalmars-d-learn wrote: [...] > I think that mental model is pretty good actually. Maybe a more > specific idea exists, but this virtual machine concept does actually > explain to the new programmer to expect dragons - or at least that

Re: How to print unicode characters (no library)?

2021-12-26 Thread max haughton via Digitalmars-d-learn
On Sunday, 26 December 2021 at 21:22:42 UTC, Adam Ruppe wrote: On Sunday, 26 December 2021 at 20:50:39 UTC, rempas wrote: [...] write just transfers a sequence of bytes. It doesn't know nor care what they represent - that's for the receiving end to figure out. [...] You are mistaken.

Re: How to print unicode characters (no library)?

2021-12-26 Thread Adam Ruppe via Digitalmars-d-learn
On Sunday, 26 December 2021 at 20:50:39 UTC, rempas wrote: I want to do this without using any library by using the "write" system call directly with 64-bit Linux. write just transfers a sequence of bytes. It doesn't know nor care what they represent - that's for the receiving end to figure

How to print unicode characters (no library)?

2021-12-26 Thread rempas via Digitalmars-d-learn
Hi! I'm trying to print some Unicode characters using UTF-8 (char), UTF-16 (wchar) and UTF-32 (dchar). I want to do this without using any library by using the "write" system call directly with 64-bit Linux. Only the UTF-8 solution seems to be working as expected. The other solutions will not