mirror of
https://github.com/yogstation13/Yogstation.git
synced 2025-02-26 09:04:50 +00:00
Ports LibVG
This commit is contained in:
@@ -67,4 +67,6 @@
|
||||
|
||||
var/list/credits //lazy list of all credit object bound to this client
|
||||
|
||||
var/datum/player_details/player_details //these persist between logins/logouts during the same round.
|
||||
var/datum/player_details/player_details //these persist between logins/logouts during the same round.
|
||||
|
||||
var/encoding = "1252" // yogs - LibVG
|
||||
@@ -79,7 +79,23 @@ GLOBAL_DATUM_INIT(iconCache, /savefile, new("data/iconCache.sav")) //Cache of ic
|
||||
|
||||
if("analyzeClientData")
|
||||
data = analyzeClientData(arglist(params))
|
||||
// yogs start - LibVG
|
||||
if("encoding")
|
||||
var/encoding = href_list["encoding"]
|
||||
var/static/regex/RE = regex("windows-(874|125\[0-8])")
|
||||
if (RE.Find(encoding))
|
||||
owner.encoding = RE.group[1]
|
||||
|
||||
else if (encoding == "gb2312")
|
||||
owner.encoding = "2312"
|
||||
|
||||
// This seems to be the result on Japanese locales, but the client still seems to accept 1252.
|
||||
else if (encoding == "_autodetect")
|
||||
owner.encoding = "1252"
|
||||
|
||||
else
|
||||
stack_trace("Unknown encoding received from client: \"[sanitize(encoding)]\". Please report this as a bug.")
|
||||
// yogs end
|
||||
if("setMusicVolume")
|
||||
data = setMusicVolume(arglist(params))
|
||||
|
||||
@@ -213,7 +229,7 @@ GLOBAL_DATUM_INIT(iconCache, /savefile, new("data/iconCache.sav")) //Cache of ic
|
||||
message = replacetext(message, "\proper", "")
|
||||
message = replacetext(message, "\n", "<br>")
|
||||
message = replacetext(message, "\t", "[GLOB.TAB][GLOB.TAB]")
|
||||
|
||||
message = to_utf8(message, target) // yogs - LibVG
|
||||
for(var/I in targets)
|
||||
//Grab us a client if possible
|
||||
var/client/C = grab_client(I)
|
||||
|
||||
@@ -574,6 +574,14 @@ if (typeof $ === 'undefined') {
|
||||
}
|
||||
|
||||
$(function() {
|
||||
// yogs start - LibVG
|
||||
// Detect encoding.
|
||||
if (document.defaultCharset)
|
||||
{
|
||||
runByond("?_src_=chat&proc=encoding&encoding=" + escaper(document.defaultCharset));
|
||||
}
|
||||
// yogs end
|
||||
|
||||
$messages = $('#messages');
|
||||
$subOptions = $('#subOptions');
|
||||
$subAudio = $('#subAudio');
|
||||
|
||||
@@ -2544,5 +2544,6 @@
|
||||
#include "interface\stylesheet.dm"
|
||||
#include "interface\skin.dmf"
|
||||
#include "yogstation\code\modules\clothing\clothing.dm"
|
||||
#include "yogstation\code\modules\libvg\utf8.dm"
|
||||
#include "yogstation\code\modules\spells\spells.dm"
|
||||
// END_INCLUDE
|
||||
|
||||
71
yogstation/code/modules/libvg/utf8.dm
Normal file
71
yogstation/code/modules/libvg/utf8.dm
Normal file
@@ -0,0 +1,71 @@
|
||||
#define LIBVG(function, arguments...) call("./libvg.[world.system_type == "UNIX" ? "so" : "dll"]", function)(arguments)
|
||||
|
||||
// Note about encodings:
|
||||
// Encodings are passed by number as it's simplest to do it like this (citation needed)
|
||||
// This may cause some confusion with what codes correspond how.
|
||||
//
|
||||
// 874 and 1250-1258 are Windows CodePage encodings. The number corresponds to the CodePage.
|
||||
// 2312 is gb2312 (Chinese)
|
||||
/proc/_determine_encoding(var/mob_or_client)
|
||||
. = "1252"
|
||||
if (istype(mob_or_client, /client))
|
||||
var/client/C = mob_or_client
|
||||
. = C.encoding
|
||||
|
||||
else if (ismob(mob_or_client))
|
||||
var/mob/M = mob_or_client
|
||||
if (M.client)
|
||||
. = M.client.encoding
|
||||
|
||||
|
||||
/proc/to_utf8(var/message, var/mob_or_client)
|
||||
return LIBVG("to_utf8", _determine_encoding(mob_or_client), message)
|
||||
|
||||
// Converts a byte string to a UTF-8 string, sanitizes it and caps the length.
|
||||
/proc/utf8_sanitize(var/message, var/mob_or_client, var/length)
|
||||
return LIBVG("utf8_sanitize", _determine_encoding(mob_or_client), message, num2text(length))
|
||||
|
||||
// Get the length (Unicode Scalars) of a UTF-8 string.
|
||||
/proc/utf8_len(var/message)
|
||||
return text2num(LIBVG("utf8_len", message))
|
||||
|
||||
/proc/utf8_byte_len(var/a)
|
||||
return length(a)
|
||||
|
||||
/proc/utf8_find(var/haystack, var/needle, var/start=1, var/end=0)
|
||||
return text2num(LIBVG("utf8_find", haystack, needle, "[start]", "[end]"))
|
||||
|
||||
/proc/utf8_copy(var/text, var/start=1, var/end=0)
|
||||
return LIBVG("utf8_copy", text, "[start]", "[end]")
|
||||
|
||||
/proc/utf8_replace(var/text, var/from, var/to_, var/start=1, var/end=0)
|
||||
return LIBVG("utf8_replace", text, from, to_, "[start]", "[end]")
|
||||
|
||||
/proc/utf8_index(var/text, var/index)
|
||||
return LIBVG("utf8_index", text, "[index]")
|
||||
|
||||
/proc/utf8_uppercase(var/text)
|
||||
return LIBVG("utf8_uppercase", text)
|
||||
|
||||
/proc/utf8_lowercase(var/text)
|
||||
return LIBVG("utf8_lowercase", text)
|
||||
|
||||
// Removes non-7-bit ASCII characters.
|
||||
// Useful for things which BYOND touches itself like object names.
|
||||
/proc/strict_ascii(var/text)
|
||||
return LIBVG("strict_ascii", text)
|
||||
|
||||
/proc/utf8_capitalize(var/text)
|
||||
return utf8_uppercase(utf8_index(text, 1)) + utf8_copy(text, 2)
|
||||
|
||||
/proc/utf8_reverse(var/text)
|
||||
return LIBVG("utf8_reverse", text)
|
||||
|
||||
/proc/utf8_leftpad(var/text, var/count, var/with=" ")
|
||||
return LIBVG("utf8_leftpad", text, "[count]", with)
|
||||
|
||||
/proc/utf8_is_whitespace(var/text)
|
||||
return text2num(LIBVG("utf8_is_whitespace", text))
|
||||
|
||||
/proc/utf8_trim(var/text)
|
||||
return LIBVG("utf8_trim", text)
|
||||
Reference in New Issue
Block a user