Page 1 of 1
Allowing chars
Posted: February 20th, 2012, 3:43 pm
by BobKare
Hey.
I just got a couple of questions.
Is it safe to allow characters like æøå and & in the chat?
If so, where in the code is this written?
Thanks,
~BobKare
Re: Allowing chars
Posted: February 20th, 2012, 5:02 pm
by fragmer
You will not be able to allow such characters, because Minecraft client does not support extended ASCII or Unicode.
Re: Allowing chars
Posted: February 20th, 2012, 5:03 pm
by Hellenion
I believe those are not accepted by the client software, fCraft would be able to handle them, but I'm not sure if the Notchian clients will. Most of the time, unknown characters will choke the client causing a horrible, slow death, I wouldn't experiment with strange characters on public servers if I were you.
if you really want to push this through, look for the function "ContainsValidCharacters" or "IsValidName" or something similar, it'll eventually lead you to where the characters are evaluated.
Re: Allowing chars
Posted: February 20th, 2012, 5:52 pm
by boblol0909
If a message ends with & and no number after it I believe it will crash every client that receives it.
Re: Allowing chars
Posted: February 20th, 2012, 5:55 pm
by BobKare
Thanks.
Re: Allowing chars
Posted: February 20th, 2012, 5:58 pm
by fragmer
You dont need to worry about message contents if you use Player.Message(). fCraft will take care of line-wrapping and potential crashing for you. Output sanitizing and wrapping is done in fCraft.LineWrapper class (fCraft/Networking/LineWrapper.cs)
Re: Allowing chars
Posted: February 22nd, 2012, 1:31 pm
by Jonty800
How do we get all these to work Frag?
My past attempts always return with a '?'
Re: Allowing chars
Posted: February 22nd, 2012, 1:35 pm
by Intertoothh
fragmer wrote:You will not be able to allow such characters, because Minecraft client does not support extended ASCII or Unicode.
Re: Allowing chars
Posted: February 22nd, 2012, 1:37 pm
by PyroPyro
Jonty800 wrote:How do we get all these to work Frag?
My past attempts always return with a '?'
I saw that on some servers, that can be done... Don't know how.
Re: Allowing chars
Posted: February 22nd, 2012, 1:39 pm
by Jonty800
Yeah, mcforge has this, and it is possible.
Fragmer told me a way about half a year ago, but I've totally forgotten.
Re: Allowing chars
Posted: February 22nd, 2012, 2:23 pm
by fragmer
Minecraft client is capable of showing most
code page 437 characters, but the client is not capable of typing any of them in. Minecraft is still unable to show any Unicode. There used to be some random client crash issues if, for example, a line of text contains no printable characters. I never bothered figuring out exact conditions that cause such client crashes.
If you'd like to modify the set of characters that fCraft allows in the output, you'll have to dive into LineWrapper.cs
Re: Allowing chars
Posted: February 23rd, 2012, 1:05 am
by Jonty800
Thanks for the help Fragmer.
I made some changes to the LineWrapper, and I used a simple
rawMessage = rawMessage.Replace("(smile)", encoding.GetString(chars)); to replace text with the byte. But I can't seem to get the emotes to come up on the chat feed, they're blank. The bytes definitely get sent because they can be copied from console and appear as an emote when pasted into the WoM chat bar (but obviously don't send when pressing enter because minecraft doesnt support them).
Is there some sort of hidden check that replaces invalid bytes with ' ' ?
Do you have any suggestions on how I can fix this problem?
Re: Allowing chars
Posted: February 23rd, 2012, 1:58 am
by fragmer
Like I said, the client is very buggy when it comes to showing those non-standard characters. You may have to experiment a bit to get them to work. Maybe they have to be preceded by some code? I seem to vaguely recall those nonprintable characters requiring the null ('\0' or (char)0) somewhere in the string.
Re: Allowing chars
Posted: September 7th, 2012, 10:31 am
by Jonty800
Ahh memories.
I figured this out, if anyone would like a tutorial, feel free to PM me.
Re: Allowing chars
Posted: September 7th, 2012, 8:45 pm
by Hellenion
fragmer, suggestion: Use those fancy box drawing chars to create awesome/retro menus.