Advertisement
Guest User

Untitled

a guest
Dec 20th, 2014
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.24 KB | None | 0 0
  1. string text = "マルチバイト文字";
  2. int size = 10; // 10バイト
  3. Encoding e = System.Text.Encoding.GetEncoding("Shift_JIS");
  4. string result = new String(text.TakeWhile((c, i) => e.GetByteCount(text.Substring(0, i + 1)) <= size).ToArray());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement