//超過10bytes則截斷
例: title=超過10bytes則截斷
var titlebytes = title.Length;
var minbyts = 10;
for (var i = 0; i < title.Length; i++) if (((int)title[i]) > 127) {
titlebytes++; minbyts--; } //(轉換)中文字為2位元
if (titlebytes > 10) { title =
title.Substring(0, minbyts); } else { title = title.Substring(0, title.Length);
} //截斷多餘文字
結果:超過10byte
Comments
Post a Comment