' ========================================================================================
' Detect if the codification is valid utf-8
' ========================================================================================
FUNCTION DWSTRING.IsUtf8 (BYREF s AS STRING) AS BOOLEAN
IF LEN(s) = 0 THEN RETURN FALSE
' // Detect if it has a UTF-8 BOM
IF LEN(s) >= 3 THEN
IF ASC(s,1) = &hEF AND ASC(s,2) = &hBB AND ASC(s,3) = &hBF THEN RETURN TRUE
END IF
DIM wLen AS LONG = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, STRPTR(s), LEN(s), NULL, 0)
RETURN (wLen <> 0)
END FUNCTION
' ========================================================================================
Quote from: Paul Squires on February 15, 2026, 05:10:45 PMThanks José for the corrections. I am adding your changes to the code base. Appreciate it.
Quote from: fbfans on February 14, 2026, 02:04:36 PM1、Uncertain issue: The "Find in Files" shortcut Ctrl+Shift+F doesn't work when the Chinese input method is active, but it works fine after switching to English mode. Ctrl+Shift is used to switch between different Chinese input methods in Chinese Windows. However, I tested other functions that also use Ctrl+Shift combinations (such as Clear All Bookmarks, Uncomment Code Block), and they all work normally. I'm just reporting this.You can map that shortcut to another key combination if you wish.
Quote<various encoding issues>Let's discuss these issues again in the future once I release the next Tiko update. Maybe most will be fixed by the changes I have made.
Quote3、I noticed that the tooltip text in the status bar keeps refreshing when hovering the mouse.- Fixed: Added code to prevent main statusbar tooltip text from continuously refreshing.
Quote4、One suggestion: Regarding drag-and-drop copy, in Tiko you have to drag the selected text first and then hold Ctrl to copy, otherwise it won't work. In programs like Word, Notepad++, and EditPlus, you can either do it the Tiko way OR select text and hold Ctrl while dragging to the target location. Of course, this is just my habit—please ignore it if it's troublesome to implement.Okay, I understand what you are trying to do, although I have not (yet) been able to implement it into Tiko. You say that it works in Notepad++? I could not get it to work there either. I tried using version 8.8.1 to so a Ctrl copy drag but it did not work. I'll keep trying to find a way to do this.
QuoteI just want Tiko to get better and better, with more complete Unicode support. Please don't mind me being so detailed. Thanks again.Awesome, keep the suggestions coming.
QuoteLastly, here is the Chinese translation file. I've tried my best to make the translations accurate, but my English is limited.I have added it to the Tiko distribution and will be in the next release.
QuoteNote: hz-utf8-rom.bas, sub printhz cannot be displayed in the function list.This problem is related to you using the "End" statement in your code. It screws up the internal parser. This problem has been reported before by another user but has not yet been fixed.
function isUTF8encoded( byref s as string ) as boolean
if len(s) = 0 then return false
' Optional: Detect UTF-8 BOM
if len(s) >= 3 then
if asc(s,1)=&hEF and asc(s,2)=&hBB and asc(s,3)=&hBF then return true
end if
dim as long wlen = MultiByteToWideChar( _
CP_UTF8, _
MB_ERR_INVALID_CHARS, _ ' strict validation
strptr(s), _
len(s), _
NULL, _
0)
return (wlen <> 0)
end function
function Utf8ToAnsi( byref sUtf8 as string ) as string
dim as long wlen, alen
dim as string sUnicode, sAnsi
if len(sUtf8) = 0 then return ""
'-----------------------------------------
' Step 1: UTF‑8 → UTF‑16 (size query)
'-----------------------------------------
wlen = MultiByteToWideChar( _
CP_UTF8, _
0, _
strptr(sUtf8), _
len(sUtf8), _
NULL, _
0)
if wlen = 0 then return ""
sUnicode = string(wlen * 2, 0)
MultiByteToWideChar( _
CP_UTF8, _
0, _
strptr(sUtf8), _
len(sUtf8), _
cast(LPWSTR, strptr(sUnicode)), _
wlen)
'-----------------------------------------
' Step 2: UTF‑16 → ANSI (size query)
'-----------------------------------------
alen = WideCharToMultiByte( _
CP_ACP, _
0, _
cast(LPCWSTR, strptr(sUnicode)), _
wlen, _
NULL, _
0, _
NULL, _
NULL)
if alen = 0 then return ""
sAnsi = string(alen, 0)
WideCharToMultiByte( _
CP_ACP, _
0, _
cast(LPCWSTR, strptr(sUnicode)), _
wlen, _
strptr(sAnsi), _
alen, _
NULL, _
NULL)
return sAnsi
end function
function UnicodeToUtf8( byref wzUnicode as DWSTRING ) as string
dim as long u8len
dim as string sUtf8
' Step 1: get required UTF‑8 size (including null terminator)
u8len = WideCharToMultiByte( _
CP_UTF8, _
0, _
cast(LPCWSTR, *wzUnicode), _
-1, _
NULL, _
0, _
NULL, _
NULL)
if u8len = 0 then return ""
' Step 2: allocate buffer
sUtf8 = string(u8len, 0)
' Step 3: convert
WideCharToMultiByte( _
CP_UTF8, _
0, _
cast(LPCWSTR, *wzUnicode), _
-1, _
strptr(sUtf8), _
u8len, _
NULL, _
NULL)
' Remove null terminator
return left(sUtf8, u8len - 1)
end function