Coder Social home page Coder Social logo

Comments (6)

Kagamia avatar Kagamia commented on July 22, 2024 1

WzLib has supported text encoding for future use. -> 3da9499

from wzcomparerr2.

KENNYSOFT avatar KENNYSOFT commented on July 22, 2024

Hmm.. that's interesting. If you can find the exact hex code for that '?' character really indicates, that would be helpful.

from wzcomparerr2.

Kagamia avatar Kagamia commented on July 22, 2024

Interesting...
I find out the bytes by tracing the source code.
GMS v.179 string.wz, position: 3413826

	using (var fs = File.OpenRead(@"C:\Users\-\Desktop\string.wz")) {
		var br = new BinaryReader(fs);
		fs.Position = 3413826;
		br.ReadByte();
		int size = br.ReadSByte(); //-24
		size = -size; //negative size -> ascii chars,  positive -> unicode chars.
		
		var buffer = br.ReadBytes(size);
		
		byte mask = 0xAA; //GMS does not encrypted now, simple XOR with mask.
		for(int i=0;i<size;i++) {
			buffer[i] ^= mask++;
		}
		
		// print hex bytes
		string.Join(" ", buffer.Select(b=>b.ToString("x2"))).Dump();

		// print decoded strings.
		Encoding.ASCII.GetString(buffer).Dump();
		Encoding.Default.GetString(buffer).Dump(); //Simplified Chinese on my laptop
		Encoding.GetEncoding(949).GetString(buffer).Dump(); //Korean code page
		Encoding.GetEncoding(1252).GetString(buffer).Dump(); //West European code page
	}

Output:

41 72 63 61 6e 65 20 53 79 6d 62 6f 6c 3a a0 4c 61 63 68 65 6c 65 69 6e
Arcane Symbol:?Lachelein
Arcane Symbol:燣achelein
Arcane Symbol:쟊achelein
Arcane Symbol: Lachelein

The ? is a0H (1010 0000b) here.
WcR2 treat them as ANSI string so weird chars appeared on respective Windows systems. 😆

Is there a better way to decode these string? or, always use ASCII Encoding like Lab?

from wzcomparerr2.

Sunaries avatar Sunaries commented on July 22, 2024

Are there pros and cons to using ASCII compared to ANSI?

from wzcomparerr2.

Kagamia avatar Kagamia commented on July 22, 2024

I am almost sure that GMS client use CP1252 fixed instead of local Ansi encoding.
According to Wiki-CP1252, char a0H means nbsp here, so it is rendered normally in game.

Further, variant MS clients use a suitable encoding as their default Encoding, to decode ansi strings in wz, regardless of your system language and code page.

ASCII is a primitive encoding where only contains a charset of 126 chars. A character out of range will be decoded as a fallback char ?.

It's necessary to add more configuration to WzLib. I've no idea how to automaic recognize which version of wz file you are loaded. 😂

from wzcomparerr2.

Sunaries avatar Sunaries commented on July 22, 2024

@Kagamia In the 182→183 update of today it is fixed. No idea why it didn't affect in-game...

t

from wzcomparerr2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.