Wir kommen nun in die "Ich weiss nicht wie das geht aber Hauptsache es geht" - Zeit."

Moderator: MVogt

Post Reply
User avatar
Theo_Gottwald
Posts: 395
Joined: 03. Oct 2009, 08:57
Location: Herrenstr.11 * 76706 Dettenheim
Contact:

Wir kommen nun in die "Ich weiss nicht wie das geht aber Hauptsache es geht" - Zeit."

Post by Theo_Gottwald » 23. Dec 2025, 21:19

Ich muss das von Hand schreiben denn mein SPR der das sonst macht ist beschäftigt.
Er redigiert ein Buch. Ein Buch von meinem Bruder.
Es muss Rechtschreibkorrigiert werden.

Eigentllich sind die Kapitel mit >45kb teilweise zu lang um von einer lokalen KI bearbeitet zu werden.
Aber ich hab CHatGPT gesagt er soll mir ein Skript machen, "was das in Chunks redigiert."

Er nimmt also die Textdateien - die eigentlich zu große sind und verarbeitet eine nach der Anderen,
zerstückelt diese (jeweils am Ende eines Absatzes) und speichert den korrigierten Text dann.

Als Model läuft lokal das GPT-Oss 120b von OpenAI. Bis jetzt sind alle Kapitel 1A.

Wie genau das funktioniert?
Weiss ich nicht das Script hat ChatGPT gemacht. Hat nicht auf Anhieb aber recht bald funktioniert.
Und da es funktioniert hab ich es nicht im Detail untersucht.

Erinnert mich an ein paar andere Bücher die ich mittels KI schon geschrieben habe.
Die es bei AMAZON zu kaufen gibt. Das hier ist eine Beispiel:

Sun Tzu in Holland...

Ich kenne kein einziges Kapitel. Es sollte aber lustig sein.
Ich kann kein Holländisch (ich glaube es ist holländisch aber es könnte auch eine andere Sprache sein).
Es gibt das Buch in mehreren Sprachen (die Meisten davon kann ich nicht).

Wie gesagt. Ich weiss nicht was drin steht.
Ich kann die Sprache nicht in der die Bücher verfasst sind.

Trotzdem konnte ich das machen und die stehen nun zum Verkauf,

Das ist der Punkt. Wir kommen nun in die Zeit wo man Dinge tun kann für die ANDERE die EXPERTISE haben.
Durch KI ist das möglich. Es geht nicht mehr darum mit "Google nachzuschlagen wie etwas geht".
Durch die KI haben wir den Experten für fast alles immer mit dabei.

Das ist die nächste Stufe der Automatisierung.
Man muss nicht mehr Rechnen lernen oder Rechtschreibung.
Es genügt dass man etwas will und im Stande ist zu sagen WAS man will. Die KI macht das dann möglich.

Ein großer Weiser hat vorrausgesagt dass bald 40% der Bevölkerung nur noch auf dem Sofa liegen und TV schauen werden.
Denn die Arbeit macht in der Zukunft wohl die KI. Nur 30% werden sich weiterentwickeln, und 20% werden wohl aus Langeweile kriminell ... irgendwieso wird dieZukunft aussehen die wir heute mitgestalten.

Wir werden immer mehr an die Stelle kommen wo wir auch als "Fachleute" nicht mehr verstehen was da passiert
aber irgendwie halten wir es am Laufen. Genauso wie dieses Beispielscript für den SPR.

Es verwendet KI um Texte zu korrigieren (Rechtschreibung) und diese schön zu formattieren (Absätze, Überschriften).
Dabei erweitert es die Möglichkeiten der lokalen Ki über deren normale Ausgabegröße hinaus in dem es Tricks anwendet.

Als es fertig war fiel mir ein dass ich eigentlich nicht verstanden habe wie es funktioniert.
Das hat mich zu diesem Post inspiriert.
Ich denke dass wir alle das immer öfter sehen werden. Die KI macht Dinge möglich von denen wir nicht mehr verstehen wie sie funktionieren. Die wir nicht mehr kontrollieren können - nur noch an- und ausschalten.

Code: Select all

The robust fix: split the ORIGINAL at Absatz boundaries first, then correct chunk-by-chunk

This removes the whole “stateless continuation / pending prefix” fragility.

Workflow:

Normalize original chapter to CRLF.

Take the first $$MAX bytes.

Find the last CRLFCRLF inside that window using STR.RNInstr.

Cut there (Absatz boundary).

Send only that chunk to the LLM with strict “do not rewrite” rules.

Append the corrected chunk to final output.

Continue with the remaining original text.

No chat memory needed, no prefix matching needed, no risk of “split mid-meaning” (because the split is your Absatz split, not the model’s).

Complete corrected SPR script (strict, chunked, Absatz-safe, uses STR.RNInstr, legal $$xxx variables, logging)
'
'SPR Script-file: Chapter_Fix_Chunked_Stateless
'Purpose: Batch-process chapter .txt files -> corrected + print-ready output
'         Chunking is done on ORIGINAL text at Absatz boundaries (CRLFCRLF)
'Author: MINIPC\theog
'Creation date: 12-23-2025
'===========================================================
'#EXE:?path\
'#SPI:ForceWrite

$$PAT=?exeloc\Kapitel
$$TAF=?exeloc\KapitelC1

MKD.$$TAF
FEF.DoIt|$$FIA|$$PAT|*.txt
MBX.Done
ENR.

'===========================================================
:DoIt
GPP.nameonly|$$FIA|$$NAO
VAR.$$TAR=$$TAF\$$NAO.txt

PRT.----------------------------------------
PRT.File: $$NAO
PRT.Source: $$FIA
PRT.Target: $$TAR

CFF.$$FIA|$$RAW

'-----------------------------------------------------------
' Globals / Work vars (3-letter names only)
'-----------------------------------------------------------
$$BLA=[BEG]
$$BLB=[END]

$$BRK=$crlf$$crlf$
$$NL1=$crlf$
$$NL2=$lf$

$$PRO=
$$ANS=
$$OUT=

$$REM=
$$WIN=
$$CHK=
$$FIN=
$$DBG=

VIN.$$MAX=6500
VIN.$$CHP=0
VIN.$$TRY=0
VIN.$$RTM=6

VIN.$$LEN=0
VIN.$$CUT=0
VIN.$$POS=0

VIN.$$PBA=0
VIN.$$PBB=0
VIN.$$LBA=0
VIN.$$LBB=0

'-----------------------------------------------------------
' Normalize ORIGINAL newlines to CRLF
'-----------------------------------------------------------
GSB.NrmRaw

$$REM=$$RAW
$$FIN=

:Loop
LEN.$$REM|$$LEN
IVV.$$LEN=0
  PRT.Done. FinalLen follows
  LEN.$$FIN|$$LEN
  PRT.$$LEN FIN_Len
  CTF.$$TAR|$$FIN
  RET.
EIF.

VIC.$$CHP
PRT.$$CHP ChunkStart
PRT.$$LEN Rem_Len

'-----------------------------------------------------------
' Decide chunk cut position on ORIGINAL (Absatz boundary)
'-----------------------------------------------------------
GSB.CutOrg

PRT.$$CUT Cut_Len

STR.Left|$$REM|$$CUT|$$CHK

' Remove this piece from $$REM (advance)
LEN.$$REM|$$LEN
CAL.$$POS=$$CUT+1|i
STR.MidTo|$$REM|$$POS|$$LEN|$$REM

'-----------------------------------------------------------
' LLM correct + format this chunk (strict)
'-----------------------------------------------------------
GSB.FixChk

LEN.$$OUT|$$LEN
PRT.$$LEN Out_Len

' Append to final
$$FIN=$$FIN$$OUT

GTO.Loop
RET.

'===========================================================
' Subprograms
'===========================================================

:NrmRaw
' Convert CRLF->LF, remove CR, LF->CRLF
STR.CIReplace|$$RAW|$crlf$|$lf$
STS.CLEAR
STR.CIReplace|$$RAW|$cr$
STS.CLEAR
STR.CIReplace|$$RAW|$lf$|$crlf$
STS.CLEAR
RET.

'-----------------------------------------------------------

:CutOrg
' Determine $$CUT (bytes) so that chunk ends at Absatz boundary (CRLFCRLF)
' Uses STR.RNInstr over a MAX window.
VIN.$$CUT=0
VIN.$$POS=0

LEN.$$REM|$$LEN

' Last chunk fits fully
IVV.$$LEN<=$$MAX
  VIN.$$CUT=$$LEN
  RET.
EIF.

' Window = first MAX bytes
STR.Left|$$REM|$$MAX|$$WIN

' Find last CRLFCRLF in window
STR.RNInstr|$$WIN|$$BRK|1|0|0|0|1|$$POS

IVV.$$POS!0
  ' Include the full delimiter (len=4): start pos + 3
  CAL.$$CUT=$$POS+3|i
  RET.
EIF.

' No Absatz boundary inside window => very long paragraph or missing blank lines.
' Fallback: find last single CRLF in window.
PRT.WARN_No_CRLFCRLF_in_Window_FallbackTo_CRLF
STR.RNInstr|$$WIN|$$NL1|1|0|0|0|1|$$POS

IVV.$$POS!0
  ' Include CRLF (len=2): start pos + 1
  CAL.$$CUT=$$POS+1|i
  RET.
EIF.

' Worst-case fallback: hard cut at MAX (should be rare)
PRT.WARN_No_CRLF_in_Window_HardCut
VIN.$$CUT=$$MAX
RET.

'-----------------------------------------------------------

:FixChk
' Ask model to ONLY correct and format, not rewrite.
' Retries hard if markers missing or output empty.

VIN.$$TRY=0
$$OUT=

:Ask
VIC.$$TRY
PRT.$$CHP AskTry
PRT.$$TRY Try_Count

GSB.MkPro

LMS.Set Model|openai/gpt-oss-20b
LMS.Ask|$$PRO|$$ANS

LEN.$$ANS|$$LEN
PRT.$$LEN ANS_Len
STR.Left|$$ANS|160|$$DBG
PRT.$$DBG ANS_Head

GSB.ExtBlk
GSB.NrmOut

LEN.$$OUT|$$LEN
IVV.$$LEN!0
  RET.
EIF.

PRT.ERROR_EmptyOrBadExtraction_Retry
IVV.$$TRY<$$RTM
  GTO.Ask
EIF.

' Final fallback: use raw chunk unchanged (still normalized already)
PRT.ERROR_FallbackToOriginalChunk
$$OUT=$$CHK
RET.

'-----------------------------------------------------------

:MkPro
$$PRO=
$$PRO+You are a strict German copy-editor and typesetter.$crlf$
$$PRO+TASK: Return the SAME content as INPUT, but corrected and print-ready.$crlf$
$$PRO+$crlf$
$$PRO+Hard rules (must follow):$crlf$
$$PRO+- Do NOT rewrite, do NOT paraphrase, do NOT add, do NOT remove content.$crlf$
$$PRO+- Preserve meaning, facts, order, and paragraph structure.$crlf$
$$PRO+- Only fix spelling/grammar/punctuation, typography, and whitespace.$crlf$
$$PRO+- Keep Absatz breaks exactly (blank line stays blank line).$crlf$
$$PRO+- If this chunk contains the chapter headline as first line and this is PART=1:$crlf$
$$PRO+  Replace ONLY that first line with a better German chapter headline.$crlf$
$$PRO+- If PART>1: Do NOT invent a headline.$crlf$
$$PRO+$crlf$
$$PRO+Return ONLY between markers, nothing else:$crlf$
$$PRO+$$BLA$crlf$
$$PRO+<text>$crlf$
$$PRO+$$BLB$crlf$
$$PRO+$crlf$
$$PRO+PART=$$CHP$crlf$
$$PRO+$crlf$
$$PRO+INPUT:$crlf$
$$PRO+$$BLA$crlf$
$$PRO+$$CHK$crlf$
$$PRO+$$BLB
RET.

'-----------------------------------------------------------

:ExtBlk
' Manual block extract between $$BLA and $$BLB (avoid BLO.* fragility)
$$OUT=
VIN.$$PBA=0
VIN.$$PBB=0

LEN.$$BLA|$$LBA
LEN.$$BLB|$$LBB

IVC.$$ANS=$$BLA
  POP.$$PBA
EIF.

IVC.$$ANS=$$BLB
  POP.$$PBB
EIF.

PRT.$$PBA BLA_Pos
PRT.$$PBB BLB_Pos

IVV.$$PBA=0
  RET.
EIF.

IVV.$$PBB=0
  RET.
EIF.

IVV.$$PBB<=$$PBA
  RET.
EIF.

CAL.$$POS=$$PBA+$$LBA|i
CAL.$$CUT=$$PBB-1|i
STR.MidTo|$$ANS|$$POS|$$CUT|$$OUT

RET.

'-----------------------------------------------------------

:NrmOut
' Normalize output newlines to CRLF (same as raw)
STR.CIReplace|$$OUT|$crlf$|$lf$
STS.CLEAR
STR.CIReplace|$$OUT|$cr$
STS.CLEAR
STR.CIReplace|$$OUT|$lf$|$crlf$
STS.CLEAR
RET.

Why this version fixes your log symptoms

No $$PEN / prefix mechanism at all → cannot fall into “ADD=0, REM=OUT” loops.

Chunk split is done on original using STR.RNInstr → always Absatz-aligned by construction.

IVV comparisons use ! where needed (I avoided <> entirely).

Extraction uses a manual marker parser (no dependence on BLO.Block Get First behavior).

Prompt is content-preserving (no rewriting/hallucination), only correction + typography.

Strict retries are present; after $$RTM failures it falls back to original chunk (and logs it).

User avatar
Theo_Gottwald
Posts: 395
Joined: 03. Oct 2009, 08:57
Location: Herrenstr.11 * 76706 Dettenheim
Contact:

Re: Wir kommen nun in die "Ich weiss nicht wie das geht aber Hauptsache es geht" - Zeit."

Post by Theo_Gottwald » 31. Dec 2025, 20:32

Der Ein und Andere wird nun denken "Wenn er das Script dazu bringen kann, etwas zu übersetzen.
Dass ist ja so wie wenn man es einem Mitarbeiter gibt und sagtt "Übersetz das Mal".
Ja, gena so ist das.

Aber dann kann man doch auch "mehrere Mitarbeiter" simulieren. So wie eine Pipeline.
Also ...
1. Mitarbeiter 1 Übersetzt gibt das Resultat weiter an
2. Mitarbeiter 2 der diverse andere Änderngen macht und das dann weitergibt an
3. Mitarbeiter 3 der noch Mal alles durchsieht und verfeinert ...
usw.

JA, das GEHT. Das Script dazu findet Ihr unten.
Und wer den SPR hat kann das auch machen, es liegt dem SPR auch noch ein Tool bei mit dem
aus den Textdateien das fertige hochladbare Buch erstellen kann (also das rtf).

Auch interessant. Nach 3 Pipelinestufen wertet ChatGPT 5.2 das Resultat als "besser" als das was er selbst
aus der gleichen Vorlage erstellt hat:

Code: Select all

2) Comparaison directe V1 vs V2 (par chapitre)
Chapitre	Score V1	Score V2	Verdict
Ch.10		965			985			V2 gagne (structure + polish).
Ch.11		935			965			V2 gagne (moins “assertif”, plus éditorial).
Ch.12		975			988			V2 gagne (accroche + style + cohérence).
Lokale KI schlägt Cloud KI. In dem Fall.
Kommt nicht so oft vor.

Das Resultat gibt es schon:
Rainer Gottwald * Alles auf Sieg

und bald in noch mehr Sprachen. Hier ist der Code.

Code: Select all

'
'SPR Script-file: Chapter_Fix_Full_Stateless
'Purpose: Batch-process chapter .txt files -> corrected + print-ready output (ONE RUN, no chunking)
'Author: MINIPC\theog
'Creation date: 12-30-2025
'===========================================================
'#EXE:?path\
'#SPI:ForceWrite

$$PAT=?exeloc\DE_V1
$$TAF=?exeloc\Target_FRAB

VAR.$$MOD=qwenlong-30b-creative-orpo-v3
'VAR.$$MOD=openai/gpt-oss-20b

VAR.$$LNG=French  

MKD.$$TAF

$$NBS=
$$BAD=
$$FIX=
$$RPL=
GSB.InitUtf8

FEF.DoIt|$$FIA|$$PAT|*.txt
MBX.Done
ENR.

'===========================================================
:DoIt
GPP.nameonly|$$FIA|$$NAO
VAR.$$TAR=$$TAF\$$NAO.txt
IEF.$$TAR
  RET.
EIF.
IVS.$$NAO=Upload
  RET.
EIF.

IVS.$$NAO=Rename
  RET.
EIF.

IVS.$$NAO=Changes
  RET.
EIF.

PRT.----------------------------------------
PRT.File: $$NAO
PRT.Source: $$FIA
PRT.Target: $$TAR

'-----------------------------------------------------------
' Read full source file
'-----------------------------------------------------------
CFF.$$FIA|$$RAW

'-----------------------------------------------------------
' Markers + work vars (3-letter names only)
'-----------------------------------------------------------
$$BLA=[BEG]
$$BLB=[END]

$$BRK=$crlf$$crlf$
$$NL1=$crlf$
$$NL2=$lf$

$$PRO=
$$ANS=
$$OUT=
$$DBG=

VIN.$$TRY=0
VIN.$$RTM=6

VIN.$$LEN=0
VIN.$$POS=0

VIN.$$PBA=0
VIN.$$PBB=0
VIN.$$LBA=0
VIN.$$LBB=0

'-----------------------------------------------------------
' Normalize ORIGINAL newlines to CRLF
'-----------------------------------------------------------
GSB.NrmRaw

'-----------------------------------------------------------
' One-shot LLM correction
'-----------------------------------------------------------
GSB.Worker|1

' DO a second Pass
$$RAW=$$OUT
GSB.Worker|2

' DO a 3rd Pass
$$RAW=$$OUT
GSB.Worker|3

'-----------------------------------------------------------
' Write result
'-----------------------------------------------------------
LEN.$$OUT|$$LEN
IVV.$$LEN=0
  PRT.ERROR_NoOutput_FallbackToOriginal
  $$OUT=$$RAW
EIF.

CTF.$$TAR|$$OUT
RET.

'===========================================================
' Subprograms
'===========================================================

:NrmRaw
' Convert CRLF->LF, remove CR, LF->CRLF (ASCII-only; UTF-8 safe)
STR.Replace|$$RAW|$crlf$|$lf$
STR.Replace|$$RAW|$cr$|
STR.Replace|$$RAW|$lf$|$crlf$
RET.


'-----------------------------------------------------------

:Worker
$$PRN=§§_01

VIN.$$TRY=0
$$OUT=

:Ask
VIC.$$TRY
PRT.AskTry: $$TRY

SCS.$$PRN
CAN.1
  GSB.MkPro_01
CAN.2
  GSB.MkPro_02
CAN.3
  GSB.MkPro_03
CAE.
  MBX.Error with Workernumber
  END.
ESC.

' Set your model here:
LMS.Set Model|$$MOD

LMS.Ask|$$PRO|$$ANS

LEN.$$ANS|$$LEN
PRT.Len: $$LEN after calling Worker $$PRN.
STR.Left|$$ANS|200|$$DBG
PRT.ANS_Head: $$DBG

GSB.ExtBlk
GSB.Utf8QA

LEN.$$OUT|$$LEN
IVV.$$LEN!0
  RET.
EIF.

PRT.ERROR_EmptyOrBadExtraction_Retry
IVV.$$TRY<$$RTM
  GTO.Ask
EIF.

' Final fallback: use original (already normalized)
PRT.ERROR_FallbackToOriginalText
$$OUT=$$RAW
RET.

'-----------------------------------------------------------

:MkPro_01
$$PRO=
$$PRO+You are a strict Expert- and state certified Translator.$crlf$
$$PRO+TASK: Completely translate/rework this content to print-ready High-Class $$LNG-Langage.$crlf$
$$PRO+$crlf$
$$PRO+Hard rules (must follow):$crlf$
$$PRO+- Add valable details the result must be larger then the original text.$crlf$
$$PRO+- Generally preserve meaning, facts, order, and paragraph structure.$crlf$
$$PRO+- Translate then fix spelling/grammar/punctuation, typography, and whitespace.$crlf$
$$PRO+- Keep Absatz breaks (blank line stays blank line).$crlf$
$$PRO+$crlf$
$$PRO+- Return ONLY between markers, nothing else:$crlf$
$$PRO+$$BLA$crlf$
$$PRO+<text>$crlf$
$$PRO+$$BLB$crlf$
$$PRO+$crlf$
$$PRO+INPUT:$crlf$
$$PRO+$$BLA$crlf$
$$PRO+$$RAW$crlf$
$$PRO+$$BLB
RET.

'-----------------------------------------------------------
:MkPro_02
$$PRO=
$$PRO+You are a Proof-Reader, and KDP-Expert.$crlf$
$$PRO+TASK: Completely fix/rework this content to print-ready High-Class $$LNG-Langage.$crlf$
$$PRO+$crlf$
$$PRO+Hard rules (must follow):$crlf$
$$PRO+- Add valable details the result must be larger then the original text.$crlf$
$$PRO+- Generally preserve meaning, facts, order, and paragraph structure.$crlf$
$$PRO+- Fix spelling/grammar/punctuation, typography, and whitespace.$crlf$
$$PRO+- The resulting text must be at least 25% larger then Input-Text so add valuable detail where it makes sense for the reader.$crlf$
$$PRO+$crlf$
$$PRO+- Return ONLY between markers, nothing else:$crlf$
$$PRO+$$BLA$crlf$
$$PRO+<text>$crlf$
$$PRO+$$BLB$crlf$
$$PRO+$crlf$
$$PRO+INPUT:$crlf$
$$PRO+$$BLA$crlf$
$$PRO+$$RAW$crlf$
$$PRO+$$BLB
RET.
'-----------------------------------------------------------
:MkPro_03
$$PRO=
$$PRO+You are a strict Proof-Reader, KDP-Expert and Typesetter.$crlf$
$$PRO+TASK: Completely fix/rework this content to print-ready High-Class $$LNG-Langage.$crlf$
$$PRO+$crlf$
$$PRO+Hard rules (must follow):$crlf$
$$PRO+- Add valable details the result must be larger then the original text.$crlf$
$$PRO+- Keep Absatz breaks and add more if we need more(blank line stays blank line) to make it better readable.$crlf$
$$PRO+- We need one crlf after the Headline and one after the Subheadline before the text starts.$crlf$
$$PRO+- The resulting text must be at least 25% larger then Input-Text so add valuable detail where it makes sense for the reader.$crlf$
$$PRO+$crlf$
$$PRO+- Return ONLY between markers, nothing else:$crlf$
$$PRO+$$BLA$crlf$
$$PRO+<text>$crlf$
$$PRO+$$BLB$crlf$
$$PRO+$crlf$
$$PRO+INPUT:$crlf$
$$PRO+$$BLA$crlf$
$$PRO+$$RAW$crlf$
$$PRO+$$BLB
RET.
'-----------------------------------------------------------

:ExtBlk
' Manual block extract between $$BLA and $$BLB (avoid BLO.* fragility)

$$OUT=
VIN.$$PBA=0
VIN.$$PBB=0

LEN.$$BLA|$$LBA
LEN.$$BLB|$$LBB

IVC.$$ANS=$$BLA
  POP.$$PBA
EIF.

IVC.$$ANS=$$BLB
  POP.$$PBB
EIF.

PRT.BLA_Pos: $$PBA
PRT.BLB_Pos: $$PBB

IVV.$$PBA=0
  RET.
EIF.

IVV.$$PBB=0
  RET.
EIF.

IVV.$$PBB<=$$PBA
  RET.
EIF.

' Extract between markers (start after BLA, end before BLB)
CAL.$$POS=$$PBA+$$LBA|i
CAL.$$LEN=$$PBB-1|i
STR.MidTo|$$ANS|$$POS|$$LEN|$$OUT
GSB.NrmOut
RET.

'-----------------------------------------------------------

:NrmOut
' Normalize output newlines to CRLF (ASCII-only; UTF-8 safe)
STR.Replace|$$OUT|$crlf$|$lf$
STR.Replace|$$OUT|$cr$|
STR.Replace|$$OUT|$lf$|$crlf$

' Replace UTF-8 NBSP (C2 A0) with normal space
$$SPA=$sp$
STR.Replace|$$OUT|$$NBS|$$SPA

' Repair known corruption: C3 20 -> C3 A0
STR.Replace|$$OUT|$$BAD|$$FIX

RET.


:InitUtf8
' Build UTF-8 byte sequences using CHR. only (no literal special chars)

' $$NBS = C2 A0 (NBSP)
CHR.194|$$C01
CHR.160|$$C02
$$NBS=
$$NBS+$$C01
$$NBS+$$C02

' $$BAD = C3 20 (broken "à " pattern created by bad A0->20 replace)
CHR.195|$$C03
CHR.32|$$C04
$$BAD=
$$BAD+$$C03
$$BAD+$$C04

' $$FIX = C3 A0 (à in UTF-8)
CHR.195|$$C05
CHR.160|$$C06
$$FIX=
$$FIX+$$C05
$$FIX+$$C06

' $$RPL = EF BF BD (U+FFFD replacement char in UTF-8)
CHR.239|$$C07
CHR.191|$$C08
CHR.189|$$C09
$$RPL=
$$RPL+$$C07
$$RPL+$$C08
$$RPL+$$C09

RET.

:Utf8QA
' Detect UTF-8 replacement bytes EF BF BD in $$OUT
' If present: repair once; if still present, clear $$OUT to force retry

VIN.$$POS=0
IVC.$$OUT=$$RPL
  POP.$$POS
EIF.

IVV.$$POS=0
  RET.
EIF.

PRT.ERROR_UTF8_ReplacementFound

GSB.NrmOut

VIN.$$POS=0
IVC.$$OUT=$$RPL
  POP.$$POS
EIF.

IVV.$$POS!0
  PRT.ERROR_UTF8_StillBad_ForceRetry
  $$OUT=
EIF.

RET.


Post Reply

Return to “Package Robot”

Who is online

Users browsing this forum: No registered users and 4 guests