' split() double quotation support ' by mieki256 ' License: CC0 / Public Domain ' Last updated: <2024/02/15 03:48:30 +0900> #ifndef __SPLITDQ__ #define __SPLITDQ__ Sub Splitdq(byref text As String, byref delim As String, result() as String) If text = "" Then Return Dim As ubyte ptr cp = strptr(text) Dim As ubyte ptr dp = strptr(delim) Dim As Integer slen = Len(text) Dim As Integer pi = 0 Dim As Integer i = 0 Dim As Boolean dqfg = False Dim As String s = "" Do If dqfg Then ' check double quotation pair If (*cp = 34) Then dqfg = False ElseIf (*cp = 34) Then ' found double quotation dqfg = True ElseIf (*cp = *dp) Then ' found delimiter s = Mid(text, pi + 1, (i - pi)) pi = i + 1 End If cp += 1 i += 1 If i >= slen Then s = Mid(text, pi + 1, (i - pi)) pi = i + 1 End If If s <> "" Then ReDim preserve result(UBound(result) + 1) result(UBound(result)) = s s = "" End If Loop While (i < slen) End Sub #endif