Public Class JapCharCodeGenerator

    Public allText As String
    Public curBlock As Integer
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        allText = ""
        TextBox2.Text = "Dim chars = New List(Of String)" & vbCrLf
        'TextBox2.Text = "d.AddRange({""a"", ""b"", ""c"", ""d""})"

        curBlock = 0

        Dim accum = ""
        Dim t = TextBox1.Text
        Dim x = 0
        Do
            If (t(x) = vbCr And t(x + 1) = vbLf) Or x = t.Length - 1 Then
                generateline(accum)
                accum = ""
                x += 2
                Continue Do
            End If

            accum &= t(x)
            x += 1

        Loop While x < t.Length - 2


        TextBox2.Text = allText
    End Sub

    Public Sub generateline(accum)

        If accum = "---" Then allText &= "        'Block " & curBlock & vbCrLf : curBlock += 1 : Exit Sub


        allText &= "chars.AddRange({"
        For a = 0 To accum.Length - 1

            allText &= """" & accum(a) & """"
            If a <> accum.Length - 1 Then allText &= ", "
        Next
        allText &= "})     '" & accum.Length & vbCrLf

    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Dim f = "D:\Games\PSX\Persona 2 - Batsu (NTSC-J) [SLPS-02825]\Export\FontCode\AtlusFontAppend.vb"
        Dim f2 = "D:\Games\PSX\Persona 2 - Batsu (NTSC-J) [SLPS-02825]\Export\FontCode\codes_source.txt"
        My.Computer.FileSystem.WriteAllText(f2, TextBox1.Text, False)
        My.Computer.FileSystem.WriteAllText(f, TextBox2.Text, False)

    End Sub
End Class