BASIC

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Kitty Hello

Pages: [1] 2 3 ... 698
1
GLBasic - en / Re: console program - on exit?
« on: 2019-Dec-10 »
Here's a minimal example that works for me. It might NOT work for x64 builds, yet. The problem is the atexit(int) argument.
Code: GLBasic [Select]
IMPORT "C" void atexit(int)

atexit(ADDRESSOF(OnConsoleExit))


FUNCTION OnConsoleExit%:
        STDOUT "Wohoo\n"
        KEYWAIT
ENDSUB

 

2
GLBasic - en / Re: How to create UTF-8 file?
« on: 2019-Dec-10 »
Sorry for the delay ;)
I wrote a tiny library that can convert to/from utf-8:
http://www.glbasic.com/forum/index.php?topic=11367.0

3
Code Snippets / UTF-8 (UTF8) utilities
« on: 2019-Dec-10 »
Here's how to deal with UTF-8 strings in GLBasic. It can convert to and from ISO 8895-1 (Latin-1), so you can "PRINT" UTF-8 strings, and write UTF-8 file from latin encodings.
Code: GLBasic [Select]
// --------------------------------- //
// Project: UTF8- Routines
// --------------------------------- //

//! Copyvert an ansi text with codepage latin-1 (ISO 8895-1) to a UTF-8 string.
//! Prefix the UTF8_BOM$() at the start of a file when you write it to disk.
FUNCTION UTF8_fromLatin1$: latin2$
LOCAL out$
        // https://stackoverflow.com/a/7904190/2721136
        FOR i% = 0 TO LEN(latin2$)-1
                // https://de.wikipedia.org/wiki/ISO_8859-1
                LOCAL cha = ASC(latin2$, i)
                IF cha < 0x80
                        INC out$, CHR$(cha)
                ELSE
                // all 11 bit codepoints (0x0 -- 0x7ff)
                // fit within a 2byte utf8 char
                // firstbyte = 110 +xxxxx := 0xc0 + (char>>6) MSB
                // second    = 10 +xxxxxx := 0x80 + (char& 63) LSB
                        INC out$,  CHR$(BOR(0xc0, BAND(ASR(cha,6), 0x1f))) // 2+1+5 bits
                        INC out$,  CHR$(BOR(0x80, BAND(cha, 0x3f))) // 1+1+6 bits
                ENDIF
        NEXT

        RETURN out$
ENDFUNCTION

INLINE
void Latin8FromUtf8(char* str, int slen) {
    int i = 0;

    char* dest = str;

    const char* pStrC = str;
    const char* pEnd = str + slen;
    // *pStrC != '\0' &&
    while(pStrC < pEnd) {
        const wchar_t c = wchar_t(static_cast<unsigned char>(*pStrC++));

        // U-0 to U-7F
        if((c & 0x80) == 0x00) {
            *dest++=char(c);
            continue;
        }
        // U-80 to U-7FF
        if((c & 0xE0) == 0xC0) {
            if(i<slen) {
                wchar_t d = static_cast<wchar_t>(*pStrC++);
                *dest++=(char((c&0x1f)<<6 | (d&0x3f)));
                continue;
            }
        }

        // U-800 to U-FFFF
        if((c & 0xF0) == 0xE0) {
            if(i+1<slen) {
                const wchar_t d = static_cast<wchar_t>(*pStrC++);
                const wchar_t e = static_cast<wchar_t>(*pStrC++);
                *dest++=(char((c&0x0f)<<12 | (d&0x3f)<<6 | (e&0x3f)));
                continue;
            }
        }
        // three continuation (U-10000 to U-10ffff)
        if((c & 0xF8) == 0xF0) {
            if(i+2<slen) {
                const wchar_t d = static_cast<wchar_t>(*pStrC++);
                const wchar_t e = static_cast<wchar_t>(*pStrC++);
                const wchar_t f = static_cast<wchar_t>(*pStrC++);
                *dest++=(char((((c&0x0f)<<18 | (d&0x3f)<<12 | (e&0x3f)<<6 | (f&0x3f)) + 655536)  & 0x000000ff));
                continue;
            }
        }
    }
    *dest = '\0';
}
ENDINLINE


//! Convert the utf8$ string to a Latin-1 (ISO 8895-1) string. Use this to 'PRINT' an UTF-8 string.
FUNCTION UTF8_toLatin1$: utf8$
        LOCAL copy$ = utf8$
INLINE
        char* str = copy_Str.getbuffer(1);
        Latin8FromUtf8(str, LEN(copy_Str));
        copy_Str.releasebuffer();
ENDINLINE
        RETURN copy$

ENDFUNCTION


//! Return the 3 byte UTF-8 BOM (byte order mask).
//! That is the first 3 bytes of an UTF-8 text file.
FUNCTION UTF8_BOM$:
        RETURN CHR$(0xef) + CHR$(0xbb) + CHR$(0xbf)
ENDFUNCTION
 

5
I allowed number of screens equal to number of sprites.
Also, the bug with the wrong 3D viewport on a surface is fixed. I hope to update soon.

6
GLBasic - en / Re: Compiling to html5?
« on: 2019-Nov-29 »
Oh. I should do that. I'm sorry.

7
GLBasic - en / Re: Compiling to html5?
« on: 2019-Nov-28 »
V16 does a good job for me. GACK compiles and runs fine.

8
V16 includes an x64 Windows compiler.
For Mac and Linux I'm working on a cmake project.

9
Ignore it. It's because one lib has a version info, so the resource compiler gets confused.

10
GLBasic - en / Re: Multiple poly vector shapes
« on: 2019-Oct-17 »
Polynews is faster than start/end.

11
GLBasic - en / Re: GLBasic
« on: 2019-Oct-11 »
Yes. I'm back on a Strato server. Moving was a pain, but on the long run, this is a good descission. They have robust servers and good backups. No need for me to care about the Linux.  I'm relieved now.

12
Announcements / Re: Server change
« on: 2019-Oct-10 »
The site is now running on the new server. Test UTF-8: äöü

...somehow the old attachment images are broken!?

13
Do you have code fragments or something? Pictures, maybe?

14
Announcements / Server change
« on: 2019-Sep-20 »
Our webhoster quits. I have time to the end of 2019 to move to another hoster.
I amy very anxious about the email/https certificate after the move.
On the other hand, I can move to a hoster that cares about the linux backbone, so I don't have to care about this anymore. It caused my so much headache, since I'm a total noob when it comes to this.

Just wanted to let you know.
If anyone if good at that stuff, please let me know.
I would have to:
-move the php sites (easy)
-backup all email (4 accounts. I use thunderbird. I plan to pull them all local and then copy back. Would that be OK?)
-move 3 data bases (yes, this forum too!). I have no idea, but I hope something like mysql-php offers that option...
-point the domains (3) to the new server (I hope that one is a quick one. My new hoster offers a GUI for that).
-What about the certificate for the https/email accounts?
-Anything I missed?

15
It's released and on sale now.

Pages: [1] 2 3 ... 698