#module
#deffunc mojichange str, int
mref txt, 32 : mref type, 1
mref s, 65
s = txt
strlen len, s
repeat len
peek chk, s, cnt
if (chk > 128 & (chk < 160)) | (chk > 223) : continue cnt + 2 // 2バイト文字
if (chk >= 'a') & (chk <= 'z') {
if (type = 0) | (type = 2) : chk -= 32 // 大文字化
} else {
if (chk >= 'A') & (chk <= 'Z') {
if (type = 1) | (type = 2) : chk += 32 // 小文字化
}
}
poke s, cnt, chk
loop
return
#global
sdim msg, 9, 3
msg = "大文字化", "小文字化", "大小反転"
buf = "aBcdeFGHijKlmnOpQRstuvwxYZ"
mes buf + "\n---------------------------"
repeat 3
mojichange buf, cnt // 1回目は大文字化,2回目は小文字化,3回目は反転
mes msg.cnt + " " + refstr // refstrに結果が入る
loop
stop
|