I'm lost with all the text encoding stuff...

Find quick help here to get you started with Hollywood
peceha
Posts: 111
Joined: Tue Dec 13, 2016 9:39 am
Location: Poland

Re: I'm lost with all the text encoding stuff...

Post by peceha » Tue Oct 10, 2017 9:37 pm

The above solution helped only in situation when I convert the whole file (second script) - but it didn't help when I want to look for text in the file (script below) - it still doesn't find "$00" - so I have to thing about some substitutes :D

Code: Select all

@OPTIONS {Encoding = #ENCODING_ISO8859_1}

tbl = {
	["a"]	= $58,
	["b"]	= $60,
	["c"]	= $68,
	["d"]	= $70,
	["e"]	= $78,
	["f"]	= $80,
	["g"]	= $88,
	["h"]	= $90,
	["i"]	= $98,
	["j"]	= $A0,
	["k"]	= $A8,
	["l"]	= $B0,
	["m"]	= $B8,
	["n"]	= $C0,
	["o"]	= $C8,
	["p"]	= $D0,
	["q"]	= $D8,
	["r"]	= $E0,
	["s"]	= $E8,
	["t"]	= $F0,
	["u"]	= $F8,
	["v"]	= $00,
	["w"]	= $08,
	["x"]	= $10,
	["y"]	= $18,
	["z"]	= $20,

	["A"]	= $57,
	["B"]	= $5F,
	["C"]	= $67,
	["D"]	= $6F,
	["E"]	= $77,
	["F"]	= $7F,
	["G"]	= $87,
	["H"]	= $8F,
	["I"]	= $97,
	["J"]	= $9F,
	["K"]	= $A7,
	["L"]	= $AF,
	["M"]	= $B7,
	["N"]	= $BF,
	["O"]	= $C7,
	["P"]	= $CF,
	["Q"]	= $D7,
	["R"]	= $DF,
	["S"]	= $E7,
	["T"]	= $EF,
	["U"]	= $F7,
	["V"]	= $FF,
	["W"]	= $07,
	["x"]	= $0F,
	["Y"]	= $17,
	["Z"]	= $1F,

	["ä"]	= $74,
	["ö"]	= $04,
	["ü"]	= $34,
	
	["Ä"]	= $73,
	["Ö"]	= $03,
	["Ü"]	= $33,

	["ß"]	= $4B,

	["_"]	= $47,

	[";"]	= $26,
	["="]	= $36,
	["?"]	= $46,
	["!"]	= $56,
	["#"]	= $66,
	["%"]	= $76,
	["'"]	= $86,
	[")"]	= $96,
	["+"]	= $A6,
	["-"]	= $B6,
	["/"]	= $C6,
	
	[":"]	= $1E,
	["<"]	= $2E,
	[">"]	= $3E,
	[" "]	= $4E,
	["\""]	= $5E,
;	$6E - rozdzielnik fraz w pliku
	["&"]	= $7E,
	["("]	= $8E,
	["*"]	= $9E,
	[","]	= $AE,
	["."]	= $BE,

	["0"]	= $CE,
	["1"]	= $D6,
	["2"]	= $DE,
	["3"]	= $E6,
	["4"]	= $EE,
	["5"]	= $F6,
	["6"]	= $FE,
	["7"]	= $06,
	["8"]	= $0E,
	["9"]	= $16
}

Local s$="Kei_ne her_aus_ra_gen_den Lei_stun_gen, Vor_komm_nis_se oder Ta_ten"

OpenFile(1,"org_bidat")

Local size=FileSize("org_bidat")
Local data$=ReadBytes(1,size)
Local sC=""
Local hexChain=""

For Local i=0 To StrLen(s$,#ENCODING_UTF8)-1
	Local idx=MidStr(s$,i,1,#ENCODING_UTF8)
	sC=sC..Chr(tbl[idx])
	hexChain=hexChain..hexstr(tbl[idx]).." "
Next

Local pos=FindStr(data$,sC)

DebugPrint(s$)
DebugPrint(hexChain)
DebugPrint(pos)

CloseFile(1)

User avatar
Allanon
Posts: 435
Joined: Sun Feb 14, 2010 8:53 pm
Location: Italy
Contact:

Re: I'm lost with all the text encoding stuff...

Post by Allanon » Wed Oct 11, 2017 7:24 pm

It's a fight! :lol:
----------------------------
[Allanon] Fabio Falcucci
AMC - Creative Development // Docs Site // Support Forum
Support me on Patreon for Hollywood libraries!

User avatar
airsoftsoftwair
Posts: 2450
Joined: Fri Feb 12, 2010 3:33 pm
Location: Germany
Contact:

Re: I'm lost with all the text encoding stuff...

Post by airsoftsoftwair » Sat Oct 14, 2017 1:13 am

Note that enabling compatibility mode is generally not a good idea because it will only allow your project to deal with ASCII filenames. If you want to use the string functions on strings that are not in UTF8 you need to pass #ENCODING_RAW to them or temporarily switch the encoding using SetDefaultEncoding() and then switch it back to UTF8.

Post Reply