варкрафт каждый символ кодирует разной длиной
поэтому при использовании SubString - могут случаться ошибки для non-EN шрифтов
call BJDebugMsg("privet - "+I2S(StringLength("privet"))) // en - 1
call BJDebugMsg("привет - "+I2S(StringLength("привет"))) // ru - 2
call BJDebugMsg("priвет - "+I2S(StringLength("priвет"))) 
call BJDebugMsg("你好 - "+I2S(StringLength("你好"))) // ch - 3
call BJDebugMsg("こんにちは - "+I2S(StringLength("こんにちは"))) // jp - 3
call BJDebugMsg("안녕하세요 - "+I2S(StringLength("안녕하세요"))) // ko - 3
call BJDebugMsg("☁❤♫✉ - "+I2S(StringLength("☁❤♫✉"))) // icons - 3
решением является функция FirstSymbolLength
которая определяет длину входящего символа
карта и код ниже:
Код карты
globals
	integer PLAYERS=12
	unit array u
endglobals

//host--pi

function FirstSymbolLength takes string s returns integer
	local integer i=1
	local integer j=1
	local string array Alphabet
	set Alphabet[1]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz01234 56789!\"#$%&'()*+:;<=>?@,-./[\\]^_`{|}~" //en-1 //len 95
	set Alphabet[2]="АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩабвгдеёжзийклмнопрстуфхцчшщЪЫЬЭЮЯъыьэюя" //ru-2 // len 66
	set Alphabet[3]="№" //ru-3
	if StringLength(s)>0 then
		loop
			exitwhen j>3
			set i=1
			loop
				exitwhen i>StringLength(Alphabet[j])/j
				//call BJDebugMsg(SubString(s,0,j)+" - "+SubString(Alphabet[j],(i-1)*j,i*j)+" i - "+I2S(i)+" j - "+I2S(j)+" s - "+s)
				if SubString(s,0,j)==SubString(Alphabet[j],(i-1)*j,i*j) then
					return j
				endif
				set i=i+1
			endloop
			set j=j+1
		endloop
		return 3
	else
		return 0
	endif
endfunction

function DecodeTest takes integer CodingLength, integer n returns nothing
	local string array s
	local integer len=0
	local integer i=1
	local integer start=0
	local integer end=0
	local string ss=""
	set s[1]="ABCDEFGHIJKLM"	//en-unique15 --- Length 1
	set s[2]="NOPQRSTUVWXYZ"
	set s[3]="abcdefghijklm"
	set s[4]="nopqrstuvwxyz"
	set s[5]="01234 56789"
	set s[6]="!\"#$%&'()*+"
	set s[7]=":;<=>?@,-./"
	set s[8]="[\\]^_`{|}~"
	//2
	set s[9]="АБВГДЕЁЖЗИЙКЛМ"	//ru-unique15 --- Length 2
	set s[10]="НОПРСТУФХЦЧШЩ"
	set s[11]="абвгдеёжзийклм"
	set s[12]="нопрстуфхцчшщ"
	set s[13]="ЪЫЬЭЮЯъыьэюя"
	//3
	set s[14]="№"		//ru-unique15 --- Length 3
	set s[15]="你好"		//ch --- Length 3
	set s[16]="こんにちは"	//jp --- Length 3
	set s[17]="안녕하세요"	//ko --- Length 3
	set s[18]="☁❤♫✉"	//icons --- Length 3
	if CodingLength<1 or CodingLength>3 then
		call BJDebugMsg("CodingLength is <1 or >3")
	else
		set len=StringLength(s[n])/CodingLength
		if len>15 then
			call BJDebugMsg("s["+I2S(n)+"] Length is "+I2S(len)+" > 15")
		else
			if len<1 then
				call BJDebugMsg("s["+I2S(n)+"] Length is "+I2S(len)+" < 1")
			else
				loop
					exitwhen i>15
					set start=(i-1)*CodingLength
					set end=i*CodingLength
					set ss=SubString(s[n],start,end)
					if StringLength(ss)>0 then
						call BJDebugMsg(ss+" --- Length "+I2S(end-start))
					else
						call BJDebugMsg(ss)
					endif
					set i=i+1
				endloop
				call BJDebugMsg("Length "+I2S(len)+" and "+I2S(15-len)+" (null)")
			endif
		endif
	endif
endfunction

function Start_msg takes nothing returns nothing
	call BJDebugMsg("Decode Symbols map")
	call BJDebugMsg("Command description:")
	call BJDebugMsg("-s X = check symbol coding, X = any symbol")
	call BJDebugMsg("-d X X = check decode example, decode length [1-3], string example [1-18]")
	call BJDebugMsg("-d Length 1 = [1-8]")
	call BJDebugMsg("-d Length 2 = [9-13]")
	call BJDebugMsg("-d Length 3 = [4-18]")
	call BJDebugMsg(" ")
	call BJDebugMsg("Command examples:")
	call BJDebugMsg("-s q")
	call BJDebugMsg("-s ы")
	call BJDebugMsg("-s №")
	call BJDebugMsg("-d 1 1")
	call BJDebugMsg("-d 2 9")
	call BJDebugMsg("-d 3 16")
	call BJDebugMsg("-help or -h = this info")
endfunction

function Start takes nothing returns nothing
	local string ss=GetEventPlayerChatString()
	local string s=StringCase(ss,false)
	local integer i=0
	if 1==0 then
	elseif SubString(s,0,3)=="-d " then
		call DecodeTest(S2I(SubString(s,3,4)),S2I(SubString(s,5,99)))
	elseif SubString(s,0,3)=="-s " then
		set i=FirstSymbolLength(SubString(s,3,10))
		call BJDebugMsg(SubString(ss,3,3+i)+" Coding Length "+I2S(i))
	elseif s=="-help" or s=="-h"then
		call Start_msg()
	endif
endfunction

function Ch_init takes nothing returns nothing
	local trigger t=CreateTrigger()
	local integer i=1
	loop
		exitwhen i>PLAYERS
		call TriggerRegisterPlayerChatEvent(t,Player(i-1),"-",false)
		set i=i+1
	endloop
	call TriggerAddAction(t,function Start)
endfunction

function Start_init takes nothing returns nothing
	call Ch_init()
	call Start_msg()
endfunction

function CreateAllUnits takes nothing returns nothing
	set u[1] = CreateUnit(Player(0), 'Hblm', -800, -50, 3.977)
endfunction
function InitCustomPlayerSlots takes nothing returns nothing
	// Player 0
	call SetPlayerStartLocation( Player(0), 0 )
	call SetPlayerColor( Player(0), ConvertPlayerColor(0) )
	call SetPlayerRacePreference( Player(0), RACE_PREF_NIGHTELF )
	call SetPlayerRaceSelectable( Player(0), false )
	call SetPlayerController( Player(0), MAP_CONTROL_USER )
	// Player 1
	call SetPlayerStartLocation( Player(1), 1 )
	call SetPlayerColor( Player(1), ConvertPlayerColor(1) )
	call SetPlayerRacePreference( Player(1), RACE_PREF_NIGHTELF )
	call SetPlayerRaceSelectable( Player(1), false )
	call SetPlayerController( Player(1), MAP_CONTROL_USER )
	// Player 11
	call SetPlayerStartLocation( Player(11), 2 )
	call ForcePlayerStartLocation( Player(11), 2 )
	call SetPlayerColor( Player(11), ConvertPlayerColor(11) )
	call SetPlayerRacePreference( Player(11), RACE_PREF_NIGHTELF )
	call SetPlayerRaceSelectable( Player(11), false )
	call SetPlayerController( Player(11), MAP_CONTROL_COMPUTER )
endfunction
function InitCustomTeams takes nothing returns nothing
	call SetPlayerTeam( Player(0), 0 )
	call SetPlayerTeam( Player(1), 0 )
	call SetPlayerAllianceStateAllyBJ( Player(0), Player(1), true )
	call SetPlayerAllianceStateAllyBJ( Player(1), Player(0), true )
	call SetPlayerAllianceStateVisionBJ( Player(0), Player(1), true )
	call SetPlayerAllianceStateVisionBJ( Player(1), Player(0), true )
	call SetPlayerTeam( Player(11), 1 )
endfunction
function InitAllyPriorities takes nothing returns nothing
	call SetStartLocPrioCount( 0, 1 )
	call SetStartLocPrio( 0, 0, 1, MAP_LOC_PRIO_HIGH )
	call SetStartLocPrioCount( 1, 1 )
	call SetStartLocPrio( 1, 0, 0, MAP_LOC_PRIO_HIGH )
endfunction

function main takes nothing returns nothing
	call Start_init()
	call SetCameraBounds(-3328.0 + GetCameraMargin(CAMERA_MARGIN_LEFT), -3584.0 + GetCameraMargin(CAMERA_MARGIN_BOTTOM), 3328.0 - GetCameraMargin(CAMERA_MARGIN_RIGHT), 3072.0 - GetCameraMargin(CAMERA_MARGIN_TOP), -3328.0 + GetCameraMargin(CAMERA_MARGIN_LEFT), 3072.0 - GetCameraMargin(CAMERA_MARGIN_TOP), 3328.0 - GetCameraMargin(CAMERA_MARGIN_RIGHT), -3584.0 + GetCameraMargin(CAMERA_MARGIN_BOTTOM) )
	call SetDayNightModels( "Environment\\DNC\\DNCLordaeron\\DNCLordaeronTerrain\\DNCLordaeronTerrain.mdl", "Environment\\DNC\\DNCLordaeron\\DNCLordaeronUnit\\DNCLordaeronUnit.mdl")
	call NewSoundEnvironment("Default")
	call SetAmbientDaySound("LordaeronSummerDay")
	call SetAmbientNightSound("LordaeronSummerNight")
	call SetMapMusic("Music", true, 0)
	call CreateAllUnits()
	call InitBlizzard()
endfunction
function config takes nothing returns nothing
	call SetMapName( "TRIGSTR_001" )
	call SetMapDescription( "TRIGSTR_003" )
	call SetPlayers( 3 )
	call SetTeams( 3 )
	call SetGamePlacement( MAP_PLACEMENT_TEAMS_TOGETHER )
	call DefineStartLocation( 0, -800.0, -50.0 )
	call DefineStartLocation( 1, -800.0, -50.0 )
	call DefineStartLocation( 2, -800.0, -50.0 )
	call InitCustomPlayerSlots(  )
	call InitCustomTeams(  )
	call InitAllyPriorities(  )
endfunction
скачать карту с кодом - тут
доп инфо по теме - тут
второе решение по совету IceFog - тут
`
ОЖИДАНИЕ РЕКЛАМЫ...
37
Очень полезный ресурс, продолжайте в том же духе.
14
обновление
в -s команду добавлен вывод введённого символа, а не только его длины
Загруженные файлы
Чтобы оставить комментарий, пожалуйста, войдите на сайт.