Andruk
Это у меня отработало в 2 раза быстрей, 13 против 26. Команда DisableDebugger активна, при правке её надо закомментировать, чтобы код был рабочий, потом раскомментировать чтобы провести тест времени.
А ещё вопрос, вырезатель картинок код наверно более актуальней <binary id="....</binary>.
;- TOP
EnableExplicit
DisableDebugger
;- # Constants
#SizeA = 1
#SizeU = 2
;- ● Define
Define StartTime
Define *s0
Define *a.ASCII
Define *u.Unicode
Define *mem
Define File$, idfile, idfile2, length, bytes, st$
File$ = OpenFileRequester("Выберите файл", "", "Книжка (.fb2)|*.fb2", 0)
StartTime = ElapsedMilliseconds()
If Asc(File$)
idfile = ReadFile(#PB_Any, File$)
If idfile
idfile2 = CreateFile(#PB_Any, GetPathPart(File$) + "2.fb2", #PB_Ascii)
If idfile2
length = Lof(idfile)
If length
*mem = AllocateMemory(length)
If *mem
WriteStringN(idfile2, ReplaceString(ReadString(idfile), "UTF-8", "windows-1251"))
bytes = ReadData(idfile, *mem, length)
If bytes
st$ = PeekS(*mem, bytes, #PB_UTF8)
*a = Ascii(st$)
*s0 = *a
*u = @st$
While *u\u And *a\a
If *a\a = '?' And *u\u <> '?'
; *a\a = 0
WriteData(idfile2 , *s0 , *a - *s0)
; WriteCharacter(idfile2, '&')
; WriteCharacter(idfile2, '#')
; WriteCharacter(idfile2, 'x')
WriteString(idfile2, "&#x" + Hex(*u\u) + ";")
; WriteString(idfile2, Hex(*u\u))
; WriteCharacter(idfile2, ';')
*s0 = *a + 1
EndIf
*a + #SizeA
*u + #SizeU
Wend
WriteData(idfile2 , *s0 , *a - *s0)
EndIf
EndIf
EndIf
CloseFile(idfile2)
EndIf
CloseFile(idfile)
EndIf
EndIf
StartTime = ElapsedMilliseconds() - StartTime
EnableDebugger
Debug StartTimeОтредактировано AZJIO (11.11.2025 04:12:17)


