Sub uprint_extra
(ByVal x&
, Byval y&
, Byval chars%&
, Byval length%&
, Byval kern&
, Byval do_render&
, txt_width&
, Byval charpos%&
, charcount&
, Byval colour~&
, Byval max_width&
) QPrintTextType = "ASCII"
f
= _LoadFont("cyberbit.ttf", 20, "monospace")
QPrintTextType = "ASCII"
QPrintString x
* 30, y
* uheight
, Chr$(count
) count = count + 1
BreakPoint = ",./- ;:!" 'I consider all these to be valid breakpoints. If you want something else, change them.
If QPrintTextType
= "ASCII" Or QPrintTextType
= "" Then text$
= _Trim$(AnsiTextToUtf8Text$
(temp$
)) Else text$
= temp$
count = -1
'first find the natural length of the line
p = uprintwidth(text$, i, 0)
'IF i < LEN(text$) THEN lineend = i - 1 ELSE
lineend = i
t$
= RTrim$(Left$(text$
, lineend
)) 'at most, our line can't be any longer than what fits the screen. x = 1
clean_exit:
QPrintWidth
= uprintwidth
(out$
, Len(out$
), 0)
QFontHeight = uheight
Sub QPrintString
(x
, y
, text$
) If QPrintTextType
= "ASCII" Or QPrintTextType
= "" Then temp$
= _Trim$(AnsiTextToUtf8Text$
(text$
)) Else temp$
= text$
Dim chi&
, ascii%
, unicode&
, aci%
'--- get ANSI char code, reset Unicode ---
If unicode&
= 0 Then unicode&
= 65533 'replacement character temp$ = temp$ + UnicodeToUtf8Char$(unicode&)
AnsiTextToUtf8Text$ = temp$
'--- option _explicit requirements ---
Dim uc&
, first%
, remain%
, conti%
'--- UTF-8 encoding ---
'--- standard ASCII (0-127) goes as is ---
UnicodeToUtf8Char$
= Chr$(unicode&
) '--- encode the Unicode into UTF-8 notation ---
temp$ = "": uc& = unicode& 'avoid argument side effect
first% = &B10000000: remain% = 63
first%
= &B10000000
Or (first% \
2): remain%
= (remain% \
2) conti%
= &B10000000
Or (uc&
And &B00111111
): uc&
= uc& \
64 temp$
= Chr$(conti%
) + temp$
first%
= (first%
Or uc&
): uc&
= 0 UnicodeToUtf8Char$
= Chr$(first%
) + temp$