Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translations for non english characters produce question marks in game #81

Open
enchantinggg4 opened this issue Jan 26, 2023 · 5 comments

Comments

@enchantinggg4
Copy link

For japanese, cyrillic and I'm pretty sure for almost all non latin characters

val lang = JLang() .item(Identifier("krp", "magma_helmet"), "私は自分自身をたわごと")
ResourcePack.addLang(Identifier("krp:ru_ru"), lang)

game will show ????? instead of letters in game

@Devan-Kerman
Copy link
Owner

can you verify with a .dump on your resource pack that the json contains ???s

@Devan-Kerman
Copy link
Owner

it might be that the java file you wrote those characters in isn't utf8 encoded

@enchantinggg4
Copy link
Author

Yes, it generates file json files in cp1251 encoding(windows cyrillic)
Howewer all my code files are in utf-8.

@enchantinggg4
Copy link
Author

enchantinggg4 commented Jan 29, 2023

RuntimeResourcePackImpl:

private static byte[] serialize(Object object) {
		UnsafeByteArrayOutputStream ubaos = new UnsafeByteArrayOutputStream();
		OutputStreamWriter writer = new OutputStreamWriter(ubaos);
		GSON.toJson(object, writer);
		try {
			writer.close();
		} catch(IOException e) {
			throw new RuntimeException(e);
		}
		return ubaos.getBytes();
	}

If no charset is provided, it OutputStreamWriter will use system's default charset
I think its better to set UTF-8 here or add an option to override charset somewhere in resource pack class.

I can experiment locally and if it is the case, ill make a pr

@enchantinggg4
Copy link
Author

I got it
I'm on 1.18.2, so i am using ARP 0.5.7, which doesn't have the fix for it
832b788#diff-0525a3f0d683be2e4e572c0caa32e5cd3d90c026fbb7a2cfee77fd4c29e0db55R525
It came as a crash fix for 1.19

So 0.5.7 always writes system's default charset
Is there a chance to backport this change to 1.18 version?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants