option explicit
function formatnametomac(val as string) as string
dim i as integer
dim str as string
str = ""
for i = 1 to len(val)
if clng("&h" & hex(asc(mid(val, i, 1)))) < 127 then
str = str & numtostrhex(asc(mid(val, i, 1)), 1)
else
str = str & numtostrhex(asc(mid(val, i, 1)), 2)
end if
next
for i = 1 to len(str) step 2
formatnametomac = formatnametomac & "%" & mid$(str, i, 2)
next
'formatnametomac = ""
'for i = 1 to len(str) step 4
'if len(mid(str, i, 4)) = 4 then
' formatnametomac = formatnametomac & h_to_l(mid(str, i, 4))
'else
' formatnametomac = formatnametomac & mid(str, i, 4)
'end if
'next
end function
function numtostrhex(byval num as long, byval bytlen as integer) as string
dim str as string
dim strreturn as string
dim i as integer
dim ilen as integer
str = cstr(hex(num))
ilen = bytlen * 2
strreturn = ""
if len(str) >= ilen then
strreturn = right(str, ilen)
else
for i = len(str) to ilen - 1
strreturn = strreturn & "0"
next
strreturn = strreturn & str
end if
numtostrhex = strreturn
end function
function h_to_l(val as string) as string
h_to_l = right(val, 2) & left(val, 2)
end function
ubuntu安裝GBK編碼
1 新增gbk編碼 sudo vim var lib locales supported.d local en us.utf 8 utf 8 zh cn.utf 8 utf 8 zh cn.gbk gbk zh cn.gb2312 gb2312 zh cn.gb18030 gb18030 前2個是預...
iOS編碼 如何建立gbk編碼
原文摘自 如果網頁編碼是utf 8的,可以這麼轉換為字串 如果網頁是gbk 或者gb2312 用utf8轉換的話,pagesource返回nil。這時需要使用gbk編碼做轉換,但是nsstringencoding不含gbk,怎麼辦?用另乙個方法處理一下 為什麼可以這麼處理?在nsstring.h 按...
python解析gbk編碼的xml
python解析xml,由於某些協會規定的原因,只能解析utf8和utf16的格式,而gbk和gb2312等解析的時候都會報錯,但是對於某些匯出的xml格式文件,很多都是gbk編碼的,那麼提供一種處理方式 先將xml解析成utf8格式,然後替代第一行的encoding格式,然後儲存乙個新檔案,提供後...