Skip to content

Commit

Permalink
[DOWNSTREAM] Cyrillic Support v2 (ParadiseSS13#24075)
Browse files Browse the repository at this point in the history
* cyrillic fixes ss220club/Paradise@cbdad6f

* fix: remove control characters

* utf-8 support

* more fixes

* spellbook to utf8

* Update code/modules/research/server.dm

Co-authored-by: Burzah <[email protected]>

* Update code/modules/research/server.dm

Co-authored-by: Burzah <[email protected]>

* Update code/modules/paperwork/paper.dm

Co-authored-by: Burzah <[email protected]>

* Update code/modules/paperwork/folders.dm

Co-authored-by: Burzah <[email protected]>

* Update code/modules/mob/mob_say_base.dm

Co-authored-by: Burzah <[email protected]>

* update formatting

* fix ai alerts

* fix spaceheater

* fix noticeboard

---------

Co-authored-by: Burzah <[email protected]>
  • Loading branch information
larentoun and Burzah authored Mar 11, 2024
1 parent d0514fe commit c5c911d
Show file tree
Hide file tree
Showing 68 changed files with 185 additions and 185 deletions.
36 changes: 18 additions & 18 deletions code/__HELPERS/text.dm
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@

//Returns null if there is any bad text in the string
/proc/reject_bad_text(text, max_length=512)
if(length(text) > max_length) return //message too long
if(length_char(text) > max_length) return //message too long
var/non_whitespace = 0
for(var/i=1, i<=length(text), i++)
switch(text2ascii(text,i))
for(var/i=1, i<=length_char(text), i++)
switch(text2ascii_char(text,i))
if(62,60,92,47) return //rejects the text if it contains these bad characters: <, >, \ or /
if(127 to 255) return //rejects weird letters like �
if(0 to 31) return //more weird stuff
Expand Down Expand Up @@ -103,25 +103,25 @@
/proc/reject_bad_name(t_in, allow_numbers=0, max_length=MAX_NAME_LEN)
// Decode so that names with characters like < are still rejected
t_in = html_decode(t_in)
if(!t_in || length(t_in) > max_length)
if(!t_in || length_char(t_in) > max_length)
return //Rejects the input if it is null or if it is longer than the max length allowed

var/number_of_alphanumeric = 0
var/last_char_group = 0
var/t_out = ""

for(var/i=1, i<=length(t_in), i++)
var/ascii_char = text2ascii(t_in,i)
for(var/i=1, i<=length_char(t_in), i++)
var/ascii_char = text2ascii_char(t_in,i)
switch(ascii_char)
// A .. Z
if(65 to 90) //Uppercase Letters
// A .. Z, А .. Я, Ё
if(65 to 90, 1040 to 1071, 1025) //Uppercase Letters
t_out += ascii2text(ascii_char)
number_of_alphanumeric++
last_char_group = 4

// a .. z
if(97 to 122) //Lowercase Letters
if(last_char_group<2) t_out += ascii2text(ascii_char-32) //Force uppercase first character
// a .. z, а .. я, ё
if(97 to 122, 1072 to 1103, 1105) //Lowercase Letters
if(last_char_group<2) t_out += uppertext(ascii2text(ascii_char)) //Force uppercase first character
else t_out += ascii2text(ascii_char)
number_of_alphanumeric++
last_char_group = 4
Expand Down Expand Up @@ -192,37 +192,37 @@
/proc/dd_hasprefix(text, prefix)
var/start = 1
var/end = length(prefix) + 1
return findtext(text, prefix, start, end)
return findtext_char(text, prefix, start, end)

//Checks the beginning of a string for a specified sub-string. This proc is case sensitive
//Returns the position of the substring or 0 if it was not found
/proc/dd_hasprefix_case(text, prefix)
var/start = 1
var/end = length(prefix) + 1
return findtextEx(text, prefix, start, end)
return findtextEx_char(text, prefix, start, end)

//Checks the end of a string for a specified substring.
//Returns the position of the substring or 0 if it was not found
/proc/dd_hassuffix(text, suffix)
var/start = length(text) - length(suffix)
if(start)
return findtext(text, suffix, start, null)
return findtext_char(text, suffix, start, null)
return

//Checks the end of a string for a specified substring. This proc is case sensitive
//Returns the position of the substring or 0 if it was not found
/proc/dd_hassuffix_case(text, suffix)
var/start = length(text) - length(suffix)
if(start)
return findtextEx(text, suffix, start, null)
return findtextEx_char(text, suffix, start, null)

/*
* Text modification
*/
// See bygex.dm
/proc/replace_characters(t, list/repl_chars)
for(var/char in repl_chars)
t = replacetext(t, char, repl_chars[char])
t = replacetext_char(t, char, repl_chars[char])
return t

//Strips the first char and returns it and the new string as a list
Expand Down Expand Up @@ -276,7 +276,7 @@

//Returns a string with the first element of the string capitalized.
/proc/capitalize(t as text)
return uppertext(copytext(t, 1, 2)) + copytext(t, 2)
return uppertext(copytext_char(t, 1, 2)) + copytext_char(t, 2)

//Centers text by adding spaces to either side of the string.
/proc/dd_centertext(message, length)
Expand Down Expand Up @@ -366,7 +366,7 @@
else
break
if(max_length)
input = copytext(input,1,max_length)
input = copytext_char(input, 1, max_length)
return sanitize(input, allow_lines ? list("\t" = " ") : list("\n" = " ", "\t" = " "))

/proc/trim_strip_html_properly(input, max_length = MAX_MESSAGE_LEN, allow_lines = 0)
Expand Down
3 changes: 2 additions & 1 deletion code/datums/datumvars.dm
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@

var/html = {"
<html>
<meta charset="UTF-8">
<head>
<title>[title]</title>
<style>
Expand Down Expand Up @@ -570,7 +571,7 @@
to_chat(usr, "This can only be used on instances of type /mob")
return

var/new_name = reject_bad_name(sanitize(copytext(input(usr, "What would you like to name this mob?", "Input a name", M.real_name) as text|null, 1, MAX_NAME_LEN)), allow_numbers = TRUE)
var/new_name = reject_bad_name(sanitize(copytext_char(input(usr, "What would you like to name this mob?", "Input a name", M.real_name) as text|null, 1, MAX_NAME_LEN)), allow_numbers = TRUE)
if(!new_name || !M) return

message_admins("Admin [key_name_admin(usr)] renamed [key_name_admin(M)] to [new_name].")
Expand Down
6 changes: 3 additions & 3 deletions code/datums/mind.dm
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@
if(!recipient)
recipient = current
var/list/output = list()
output.Add("<B>[current.real_name]'s Memories:</B><HR>")
output.Add("<meta charset='UTF-8'><b>[current.real_name]'s Memories:</b><hr>")
output.Add(memory)

for(var/datum/antagonist/A in antag_datums)
Expand Down Expand Up @@ -524,7 +524,7 @@
alert("Not before round-start!", "Alert")
return

var/list/out = list("<B>[name]</B>[(current && (current.real_name != name))?" (as [current.real_name])" : ""]")
var/list/out = list("<meta charset='UTF-8'><b>[name]</b>[(current && (current.real_name != name))?" (as [current.real_name])" : ""]")
out.Add("Mind currently owned by key: [key] [active ? "(synced)" : "(not synced)"]")
out.Add("Assigned role: [assigned_role]. <a href='?src=[UID()];role_edit=1'>Edit</a>")
out.Add("Factions and special roles:")
Expand Down Expand Up @@ -762,7 +762,7 @@
var/datum/objective/escape/escape_with_identity/O = new_objective
O.target_real_name = new_objective.target.current.real_name
if("custom")
var/expl = sanitize(copytext(input("Custom objective:", "Objective", objective ? objective.explanation_text : "") as text|null,1,MAX_MESSAGE_LEN))
var/expl = sanitize(copytext_char(input("Custom objective:", "Objective", objective ? objective.explanation_text : "") as text|null, 1, MAX_MESSAGE_LEN))
if(!expl)
return
new_objective = new /datum/objective
Expand Down
4 changes: 2 additions & 2 deletions code/game/!atoms.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1236,7 +1236,7 @@ GLOBAL_LIST_EMPTY(blood_splatter_icons)
if(!use_prefix)
default_value = name
else if(findtext(name, prefix) != 0)
default_value = copytext(name, length(prefix) + 1)
default_value = copytext_char(name, length_char(prefix) + 1)
else
// Either the thing has a non-conforming name due to being set in the map
// OR (much more likely) the thing is unlabeled yet.
Expand All @@ -1263,7 +1263,7 @@ GLOBAL_LIST_EMPTY(blood_splatter_icons)
return null


t = sanitize(copytext(t, 1, MAX_NAME_LEN))
t = sanitize(copytext_char(t, 1, MAX_NAME_LEN))

// Logging
var/logged_name = initial(name)
Expand Down
2 changes: 1 addition & 1 deletion code/game/gamemodes/nuclear/nuclear.dm
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@

/proc/nukelastname(mob/M as mob) //--All praise goes to NEO|Phyte, all blame goes to DH, and it was Cindi-Kate's idea. Also praise Urist for copypasta ho.
var/randomname = pick(GLOB.last_names)
var/newname = sanitize(copytext(input(M,"You are the nuke operative [pick("Czar", "Boss", "Commander", "Chief", "Kingpin", "Director", "Overlord")]. Please choose a last name for your family.", "Name change",randomname),1,MAX_NAME_LEN))
var/newname = sanitize(copytext_char(input(M,"You are the nuke operative [pick("Czar", "Boss", "Commander", "Chief", "Kingpin", "Director", "Overlord")]. Please choose a last name for your family.", "Name change", randomname), 1, MAX_NAME_LEN))

if(!newname)
newname = randomname
Expand Down
2 changes: 1 addition & 1 deletion code/game/gamemodes/objective.dm
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ GLOBAL_LIST_INIT(potential_theft_objectives, (subtypesof(/datum/theft_objective)
if(!steal_target_path)
return

var/theft_objective_name = sanitize(copytext(input("Enter target name:", "Objective target", initial(steal_target_path.name)) as text|null, 1, MAX_NAME_LEN))
var/theft_objective_name = sanitize(copytext_char(input("Enter target name:", "Objective target", initial(steal_target_path.name)) as text|null, 1, MAX_NAME_LEN))
if(!theft_objective_name)
return

Expand Down
2 changes: 1 addition & 1 deletion code/game/gamemodes/scoreboard.dm
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ GLOBAL_VAR(scoreboard) // Variable to save the scoreboard string once it's been


// Generate the score panel
var/list/dat = list("<b>Round Statistics and Score</b><br><hr>")
var/list/dat = list("<meta charset='UTF-8'><b>Round Statistics and Score</b><br><hr>")
if(SSticker.mode)
dat += SSticker.mode.get_scoreboard_stats()

Expand Down
2 changes: 1 addition & 1 deletion code/game/gamemodes/wizard/artefact.dm
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
var/wizard_name_first = pick(GLOB.wizard_first)
var/wizard_name_second = pick(GLOB.wizard_second)
var/randomname = "[wizard_name_first] [wizard_name_second]"
var/newname = sanitize(copytext(input(M, "You are the wizard's apprentice. Would you like to change your name to something else?", "Name change", randomname) as null|text,1,MAX_NAME_LEN))
var/newname = sanitize(copytext_char(input(M, "You are the wizard's apprentice. Would you like to change your name to something else?", "Name change", randomname) as null|text, 1, MAX_NAME_LEN))

if(!newname)
newname = randomname
Expand Down
2 changes: 1 addition & 1 deletion code/game/gamemodes/wizard/spellbook.dm
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,7 @@

/obj/item/spellbook/proc/wrap(content)
var/dat = ""
dat +="<html><head><title>Spellbook</title></head>"
dat +="<html><meta charset='utf-8'><head><title>Spellbook</title></head>"
dat += {"
<head>
<style type="text/css">
Expand Down
2 changes: 1 addition & 1 deletion code/game/gamemodes/wizard/wizard.dm
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
var/wizard_name_first = pick(GLOB.wizard_first)
var/wizard_name_second = pick(GLOB.wizard_second)
var/randomname = "[wizard_name_first] [wizard_name_second]"
var/newname = sanitize(copytext(input(wizard_mob, "You are the Space Wizard. Would you like to change your name to something else?", "Name change", randomname) as null|text,1,MAX_NAME_LEN))
var/newname = sanitize(copytext_char(input(wizard_mob, "You are the Space Wizard. Would you like to change your name to something else?", "Name change", randomname) as null|text, 1, MAX_NAME_LEN))

if(!newname)
newname = randomname
Expand Down
4 changes: 2 additions & 2 deletions code/game/jobs/job_exp.dm
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ GLOBAL_LIST_INIT(role_playtime_requirements, list(
if(!check_rights(R_ADMIN|R_MOD|R_MENTOR))
return
var/list/msg = list()
msg += "<html><head><title>Playtime Report</title></head><body>"
msg += "<html><meta charset='utf-8'><head><title>Playtime Report</title></head><body>"
var/datum/job/theirjob
var/jtext
msg += "<TABLE border ='1'><TR><TH>Player</TH><TH>Job</TH><TH>Crew</TH>"
msg += "<table border ='1'><tr><th>Player</th><th>Job</th><th>Crew</th>"
for(var/thisdept in EXP_DEPT_TYPE_LIST)
msg += "<TH>[thisdept]</TH>"
msg += "</TR>"
Expand Down
4 changes: 2 additions & 2 deletions code/game/machinery/camera/camera.dm
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,10 @@
to_chat(AI, "<b>[U]</b> holds <a href='?_src_=usr;show_paper=1;'>\a [itemname]</a> up to one of your cameras ...")
else
to_chat(AI, "<b><a href='?src=[AI.UID()];track=[html_encode(U.name)]'>[U]</a></b> holds <a href='?_src_=usr;show_paper=1;'>\a [itemname]</a> up to one of your cameras ...")
AI.last_paper_seen = "<HTML><HEAD><TITLE>[itemname]</TITLE></HEAD><BODY><TT>[info]</TT></BODY></HTML>"
AI.last_paper_seen = "<html><meta charset='utf-8'><head><title>[itemname]</title></head><body><tt>[info]</tt></body></html>"
else if(O.client && O.client.eye == src)
to_chat(O, "[U] holds \a [itemname] up to one of the cameras ...")
O << browse("<HTML><HEAD><TITLE>[itemname]</TITLE></HEAD><BODY><TT>[info]</TT></BODY></HTML>", "window=[itemname]")
O << browse("<html><meta charset='utf-8'><head><title>[itemname]</title></head><body><tt>[info]</tt></body></html>", "window=[itemname]")

else if(istype(I, /obj/item/laser_pointer))
var/obj/item/laser_pointer/L = I
Expand Down
8 changes: 4 additions & 4 deletions code/game/machinery/computer/card.dm
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ GLOBAL_VAR_INIT(time_last_changed_position, 0)
if(!job_in_department(SSjobs.GetJob(t1)))
return FALSE
if(t1 == "Custom")
var/temp_t = sanitize(reject_bad_name(copytext(input("Enter a custom job assignment.", "Assignment"), 1, MAX_MESSAGE_LEN), TRUE))
var/temp_t = sanitize(reject_bad_name(copytext_char(input("Enter a custom job assignment.", "Assignment"), 1, MAX_MESSAGE_LEN), TRUE))
//let custom jobs function as an impromptu alt title, mainly for sechuds
if(temp_t && scan && modify)
var/oldrank = modify.getRankAndAssignment()
Expand Down Expand Up @@ -543,7 +543,7 @@ GLOBAL_VAR_INIT(time_last_changed_position, 0)
playsound(get_turf(src), 'sound/machines/buzz-sigh.ogg', 50, 0)
visible_message("<span class='warning'>[src]: Heads may only demote members of their own department.</span>")
return FALSE
var/reason = sanitize(copytext(input("Enter legal reason for demotion. Enter nothing to cancel.","Legal Demotion"), 1, MAX_MESSAGE_LEN))
var/reason = sanitize(copytext_char(input("Enter legal reason for demotion. Enter nothing to cancel.","Legal Demotion"), 1, MAX_MESSAGE_LEN))
if(!reason || !is_authenticated(usr) || !modify)
return FALSE
var/list/access = list()
Expand All @@ -570,7 +570,7 @@ GLOBAL_VAR_INIT(time_last_changed_position, 0)
visible_message("<span class='warning'>[src]: Only the Captain or HOP may completely terminate the employment of a crew member.</span>")
return FALSE
var/jobnamedata = modify.getRankAndAssignment()
var/reason = sanitize(copytext(input("Enter legal reason for termination. Enter nothing to cancel.", "Employment Termination"), 1, MAX_MESSAGE_LEN))
var/reason = sanitize(copytext_char(input("Enter legal reason for termination. Enter nothing to cancel.", "Employment Termination"), 1, MAX_MESSAGE_LEN))
if(!reason || !has_idchange_access() || !modify)
return FALSE
var/m_ckey = modify.getPlayerCkey()
Expand Down Expand Up @@ -627,7 +627,7 @@ GLOBAL_VAR_INIT(time_last_changed_position, 0)
message_admins("[key_name_admin(usr)] has closed a job slot for job \"[j.title]\".")
return
if("remote_demote")
var/reason = sanitize(copytext(input("Enter legal reason for demotion. Enter nothing to cancel.","Legal Demotion"), 1, MAX_MESSAGE_LEN))
var/reason = sanitize(copytext_char(input("Enter legal reason for demotion. Enter nothing to cancel.","Legal Demotion"), 1, MAX_MESSAGE_LEN))
if(!reason || !is_authenticated(usr) || !scan)
return FALSE
for(var/datum/data/record/E in GLOB.data_core.general)
Expand Down
2 changes: 1 addition & 1 deletion code/game/machinery/portable_turret.dm
Original file line number Diff line number Diff line change
Expand Up @@ -963,7 +963,7 @@ GLOBAL_LIST_EMPTY(turret_icons)

if(is_pen(I)) //you can rename turrets like bots!
var/t = input(user, "Enter new turret name", name, finish_name) as text
t = sanitize(copytext(t, 1, MAX_MESSAGE_LEN))
t = sanitize(copytext_char(t, 1, MAX_MESSAGE_LEN))
if(!t)
return
if(!in_range(src, usr) && loc != usr)
Expand Down
12 changes: 6 additions & 6 deletions code/game/machinery/spaceheater.dm
Original file line number Diff line number Diff line change
Expand Up @@ -96,21 +96,21 @@
var/dat
dat = "Power cell: "
if(cell)
dat += "<A href='byond://?src=[UID()];op=cellremove'>Installed</A><BR>"
dat += "<a href='byond://?src=[UID()];op=cellremove'>Installed</a><br>"
else
dat += "<A href='byond://?src=[UID()];op=cellinstall'>Removed</A><BR>"
dat += "<a href='byond://?src=[UID()];op=cellinstall'>Removed</a><br>"

dat += "Power Level: [cell ? round(cell.percent(),1) : 0]%<BR><BR>"
dat += "Power Level: [cell ? round(cell.percent(),1) : 0]%<br><br>"

dat += "Set Temperature: "

dat += "<A href='?src=[UID()];op=temp;val=-5'>-</A>"
dat += "<a href='?src=[UID()];op=temp;val=-5'>-</a>"

dat += " [set_temperature]&deg;C "
dat += "<A href='?src=[UID()];op=temp;val=5'>+</A><BR>"
dat += "<a href='?src=[UID()];op=temp;val=5'>+</a><br>"

user.set_machine(src)
user << browse("<HEAD><TITLE>Space Heater Control Panel</TITLE></HEAD><TT>[dat]</TT>", "window=spaceheater")
user << browse("<meta charset='utf-8'><head><title>Space Heater Control Panel Панель</title></head><tt>[dat]</tt>", "window=spaceheater")
onclose(user, "spaceheater")

else
Expand Down
12 changes: 6 additions & 6 deletions code/game/machinery/status_display.dm
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ GLOBAL_LIST_EMPTY(status_displays)
line1 = message1

else
line1 = copytext("[message1]|[message1]", index1, index1 + DISPLAY_CHARS_PER_LINE)
var/message1_len = length(message1)
line1 = copytext_char("[message1]|[message1]", index1, index1 + DISPLAY_CHARS_PER_LINE)
var/message1_len = length_char(message1)
index1 += DISPLAY_SCROLL_SPEED

if(index1 > message1_len)
Expand All @@ -136,8 +136,8 @@ GLOBAL_LIST_EMPTY(status_displays)
line2 = message2

else
line2 = copytext("[message2]|[message2]", index2, index2 + DISPLAY_CHARS_PER_LINE)
var/message2_len = length(message2)
line2 = copytext_char("[message2]|[message2]", index2, index2 + DISPLAY_CHARS_PER_LINE)
var/message2_len = length_char(message2)
index2 += DISPLAY_SCROLL_SPEED

if(index2 > message2_len)
Expand Down Expand Up @@ -168,14 +168,14 @@ GLOBAL_LIST_EMPTY(status_displays)

/obj/machinery/status_display/proc/set_message(m1, m2)
if(m1)
index1 = (length(m1) > DISPLAY_CHARS_PER_LINE)
index1 = (length_char(m1) > DISPLAY_CHARS_PER_LINE)
message1 = m1
else
message1 = ""
index1 = 0

if(m2)
index2 = (length(m2) > DISPLAY_CHARS_PER_LINE)
index2 = (length_char(m2) > DISPLAY_CHARS_PER_LINE)
message2 = m2
else
message2 = ""
Expand Down
2 changes: 1 addition & 1 deletion code/game/mecha/combat/honker.dm
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
return output

/obj/mecha/combat/honker/get_stats_html()
var/output = {"<html>
var/output = {"<html><meta charset='utf-8'>
<head><title>[name] data</title>
<style>
body {color: #00ff00; background: #32CD32; font-family:"Courier",monospace; font-size: 12px;}
Expand Down
4 changes: 2 additions & 2 deletions code/game/mecha/equipment/tools/medical_tools.dm
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
/obj/item/mecha_parts/mecha_equipment/medical/sleeper/proc/get_patient_stats()
if(!patient)
return
return {"<html>
return {"<html><meta charset='utf-8'>
<head>
<title>[patient] statistics</title>
<script language='javascript' type='text/javascript'>
Expand Down Expand Up @@ -383,7 +383,7 @@
return

/obj/item/mecha_parts/mecha_equipment/medical/syringe_gun/proc/get_reagents_page()
var/output = {"<html>
var/output = {"<html><meta charset='utf-8'>
<head>
<title>Reagent Synthesizer</title>
<script language='javascript' type='text/javascript'>
Expand Down
Loading

0 comments on commit c5c911d

Please sign in to comment.