Created
February 20, 2012 13:00
-
-
Save taka2/1869083 to your computer and use it in GitHub Desktop.
VB.NETでSubstringB的な何か
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ' (参考) http://www.atmarkit.co.jp/bbs/phpBB/viewtopic.php?topic=20714&forum=7&start=8 | |
| Imports System | |
| Imports System.Text | |
| Class Test | |
| Public Shared Sub Main | |
| Dim t As New Test | |
| t.aaa() | |
| End Sub | |
| Public Sub aaa() | |
| Dim Rec As String = "@@@あ@@@い@@@う@うううう,@@@@@@@@@@@@@@@@@@@@@@@@@" | |
| 'Dim SJIS As System.Text.Encoding = System.Text.Encoding.GetEncoding("Shift-Jis") | |
| 'Dim RecB As Byte()=SJIS.GetBytes(Rec) | |
| Console.WriteLine(substringB(Rec, 0, 5)) | |
| 'Console.WriteLine(SJIS.GetString(RecB, 0, 5)) | |
| Console.WriteLine(substringB(Rec, 5, 5)) | |
| Console.WriteLine(substringB(Rec, 10, 5)) | |
| Console.WriteLine(substringB(Rec, 15, 5)) | |
| Console.WriteLine(substringB(Rec, 20, 5)) | |
| Console.WriteLine(substringB(Rec, 25, 5)) | |
| Console.WriteLine(substringB(Rec, 30, 5)) | |
| Console.WriteLine(substringB(Rec, 35, 5)) | |
| Console.WriteLine(substringB(Rec, 40, 5)) | |
| Console.WriteLine(substringB(Rec, 45, 5)) | |
| End Sub | |
| Private Function substringB(ByRef str As String, ByVal offset As Integer, ByVal bytes As Integer) As String | |
| Dim SJIS As System.Text.Encoding = System.Text.Encoding.GetEncoding("Shift-JIS") | |
| Dim RecB As Byte()=SJIS.GetBytes(str) | |
| Return SJIS.GetString(RecB, offset, bytes) | |
| End Function | |
| End Class |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment