From c5c911d252e29bbac86ffc0c9de82cbd84358310 Mon Sep 17 00:00:00 2001 From: larentoun <31931237+larentoun@users.noreply.github.com> Date: Mon, 11 Mar 2024 12:35:08 +0300 Subject: [PATCH] [DOWNSTREAM] Cyrillic Support v2 (#24075) * cyrillic fixes https://github.com/ss220club/Paradise/commit/cbdad6f11f0e0e16694cdb60f8ccb3d6dd23fe92 * fix: remove control characters * utf-8 support * more fixes * spellbook to utf8 * Update code/modules/research/server.dm Co-authored-by: Burzah <116982774+Burzah@users.noreply.github.com> * Update code/modules/research/server.dm Co-authored-by: Burzah <116982774+Burzah@users.noreply.github.com> * Update code/modules/paperwork/paper.dm Co-authored-by: Burzah <116982774+Burzah@users.noreply.github.com> * Update code/modules/paperwork/folders.dm Co-authored-by: Burzah <116982774+Burzah@users.noreply.github.com> * Update code/modules/mob/mob_say_base.dm Co-authored-by: Burzah <116982774+Burzah@users.noreply.github.com> * update formatting * fix ai alerts * fix spaceheater * fix noticeboard --------- Co-authored-by: Burzah <116982774+Burzah@users.noreply.github.com> --- code/__HELPERS/text.dm | 36 ++++++------ code/datums/datumvars.dm | 3 +- code/datums/mind.dm | 6 +- code/game/!atoms.dm | 4 +- code/game/gamemodes/nuclear/nuclear.dm | 2 +- code/game/gamemodes/objective.dm | 2 +- code/game/gamemodes/scoreboard.dm | 2 +- code/game/gamemodes/wizard/artefact.dm | 2 +- code/game/gamemodes/wizard/spellbook.dm | 2 +- code/game/gamemodes/wizard/wizard.dm | 2 +- code/game/jobs/job_exp.dm | 4 +- code/game/machinery/camera/camera.dm | 4 +- code/game/machinery/computer/card.dm | 8 +-- code/game/machinery/portable_turret.dm | 2 +- code/game/machinery/spaceheater.dm | 12 ++-- code/game/machinery/status_display.dm | 12 ++-- code/game/mecha/combat/honker.dm | 2 +- .../mecha/equipment/tools/medical_tools.dm | 4 +- code/game/mecha/mecha_topic.dm | 8 +-- code/game/objects/items/blueprints.dm | 2 +- code/game/objects/items/devices/paicard.dm | 2 +- .../objects/items/devices/voice_changer.dm | 2 +- code/game/objects/items/weapons/RCD.dm | 2 +- code/game/objects/items/weapons/manuals.dm | 24 ++++---- code/game/objects/structures/noticeboard.dm | 6 +- code/game/verbs/ooc.dm | 4 +- code/modules/admin/misc_admin_procs.dm | 4 +- code/modules/admin/outfits.dm | 2 +- .../admin/permissionverbs/permissionedit.dm | 2 +- code/modules/admin/player_panel.dm | 10 ++-- code/modules/admin/secrets.dm | 2 +- code/modules/admin/sql_notes.dm | 2 +- code/modules/admin/topic.dm | 10 ++-- code/modules/admin/verbs/adminhelp.dm | 2 +- code/modules/admin/verbs/adminpm.dm | 2 +- code/modules/admin/verbs/adminsay.dm | 4 +- code/modules/admin/verbs/deadsay.dm | 2 +- code/modules/admin/verbs/deathsquad.dm | 2 +- code/modules/admin/verbs/gimmick_team.dm | 2 +- .../admin/verbs/infiltratorteam_syndicate.dm | 2 +- code/modules/admin/verbs/ping_all_admins.dm | 2 +- code/modules/admin/verbs/pray.dm | 8 +-- code/modules/admin/verbs/randomverbs.dm | 6 +- .../admin/verbs/striketeam_syndicate.dm | 2 +- code/modules/arcade/prize_counter.dm | 2 +- .../machinery/other/area_atmos_computer.dm | 2 +- code/modules/client/preference/character.dm | 6 +- code/modules/library/book.dm | 2 +- .../modules/mob/dead/observer/observer_say.dm | 2 +- code/modules/mob/living/autohiss.dm | 10 ++-- code/modules/mob/living/living_say.dm | 4 +- .../mob/living/silicon/!silicon_mob.dm | 2 +- code/modules/mob/living/silicon/ai/!ai_mob.dm | 16 +++--- .../modules/mob/living/silicon/pai/recruit.dm | 10 ++-- code/modules/mob/mob.dm | 2 +- code/modules/mob/mob_misc_procs.dm | 56 +++++++++---------- code/modules/mob/mob_say_base.dm | 2 +- code/modules/mob/new_player/!new_player.dm | 2 +- code/modules/newscaster/obj/newspaper.dm | 2 +- code/modules/paperwork/folders.dm | 4 +- code/modules/paperwork/paper.dm | 2 +- code/modules/paperwork/paper_bundle.dm | 4 +- code/modules/paperwork/photography.dm | 2 +- code/modules/pda/PDA.dm | 1 - code/modules/pda/ai_pda.dm | 2 +- code/modules/research/server.dm | 6 +- code/modules/supply/supply_console.dm | 2 +- code/modules/telesci/gps.dm | 2 +- 68 files changed, 185 insertions(+), 185 deletions(-) diff --git a/code/__HELPERS/text.dm b/code/__HELPERS/text.dm index d58196cb480..787d1f1bdee 100644 --- a/code/__HELPERS/text.dm +++ b/code/__HELPERS/text.dm @@ -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 @@ -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 @@ -192,21 +192,21 @@ /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 @@ -214,7 +214,7 @@ /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 @@ -222,7 +222,7 @@ // 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 @@ -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) @@ -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) diff --git a/code/datums/datumvars.dm b/code/datums/datumvars.dm index a6fe725f654..252a60c8778 100644 --- a/code/datums/datumvars.dm +++ b/code/datums/datumvars.dm @@ -239,6 +239,7 @@ var/html = {" +