#3189: Improve username validation

This commit is contained in:
Outfluencer
2021-09-25 08:07:58 +10:00
committed by md_5
parent 1823f86dbb
commit 3008d7ef2f
4 changed files with 57 additions and 5 deletions

View File

@@ -7,6 +7,7 @@ import java.net.InetSocketAddress;
import java.net.SocketAddress;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Locale;
import java.util.UUID;
/**
@@ -68,6 +69,17 @@ public class Util
return String.format( "0x%02X", i );
}
/**
* Formats an char as a unicode value.
*
* @param c the character to format
* @return the unicode representation of the character
*/
public static String unicode(char c)
{
return "\\u" + String.format( "%04x", (int) c ).toUpperCase( Locale.ROOT );
}
/**
* Constructs a pretty one line version of a {@link Throwable}. Useful for
* debugging.