Public Class MyString
    '//문자열관련이다.
    Private Shared ChoSung As Char()
    Private Shared JongSung As Char()
    Private Shared JungSung As Char()

    Enum E_Hangle
        한글아님 = 0
        완성형
        자모
        초성
        중성
        종성
    End Enum
    Enum e_UnicodeHanAddress
        chosung_start = &H1100
        jungsung_start = &H1161
        jongsung_start = &H11A7
        wangsung_start = &HAC00
    End Enum

    Shared Sub New()
        ChoSung = New Char() {"ㄱ", "ㄲ", "ㄴ", "ㄷ", "ㄸ", "ㄹ", "ㅁ", "ㅂ", "ㅃ", "ㅅ", "ㅆ", "ㅇ", "ㅈ", "ㅉ", "ㅊ", "ㅋ", "ㅌ", "ㅍ", "ㅎ"}
        JungSung = New Char() {"ㅏ", "ㅐ", "ㅑ", "ㅒ", "ㅓ", "ㅔ", "ㅕ", "ㅖ", "ㅗ", "ㅘ", "ㅙ", "ㅚ", "ㅛ", "ㅜ", "ㅝ", "ㅞ", "ㅟ", "ㅠ", "ㅡ", "ㅢ", "ㅣ"}
        JongSung = New Char() {ChrW(0), "ㄱ", "ㄲ", "ㄳ", "ㄴ", "ㄵ", "ㄶ", "ㄷ", "ㄹ", "ㄺ", "ㄻ", "ㄼ", "ㄽ", "ㄾ", "ㄿ", "ㅀ", "ㅁ", "ㅂ", "ㅄ", "ㅅ", "ㅆ", "ㅇ", "ㅈ", "ㅊ", "ㅋ", "ㅌ", "ㅍ", "ㅎ"}
    End Sub

    Public Shared Function Read_ConString(ByVal CSFile As String) As String
        Dim A As New EnDec("ENDECPASSWORDKEY")
        Dim Cs As String = ""
        If System.IO.File.Exists(CSFile) = False Then
            MsgBox("연결파일이 존재하지않습니다" & vbCrLf & "로그인기능을 이용할 수 없습니다", MsgBoxStyle.Critical, "확인")
            'Return ""
        End If
        Return A.Read_STring(CSFile)
    End Function

    Private Shared Function FindIndex(ByVal list As Char(), ByVal c As Char) As Integer
        Dim i As Integer
        For i = 0 To list.Length - 1
            If list(i).Equals(c) Then
                Return i
            End If
        Next i
        Return -1
    End Function

    Public Shared Function AssembleHangul(ByVal cho As Char, ByVal jung As Char, ByVal jong As Char) As String
        If (cho.Equals(ChrW(0)) OrElse jung.Equals(ChrW(0))) Then
            Return ""
        End If
        Dim num As Short = CShort(MyString.FindIndex(MyString.ChoSung, cho))
        Dim num3 As Short = CShort(MyString.FindIndex(MyString.JungSung, jung))
        Dim num2 As Short = CShort(MyString.FindIndex(MyString.JongSung, jong))
        Dim charCode As Integer = (((((num * &H15) + num3) * &H1C) + num2) + &HAC00)
        Return ChrW(charCode)
    End Function

    Public Shared Function GetChosung(ByVal c As Char) As Char
        Dim cho As Char = ChrW(0)
        Dim jung As Char = ChrW(0)
        Dim jong As Char = ChrW(0)
        MyString.GetSplitHangul(c, (cho), (jung), (jong))
        Return cho
    End Function

    Public Shared Function GetInCountChar(ByVal vStr As String, ByVal vChar As String) As Short
        Dim num2 As Short = 0

        For Each ch As Char In vStr.ToUpper.ToCharArray
            If ch = vChar.ToUpper Then
                num2 = CShort((num2 + 1))
            End If
        Next
        Return num2
    End Function

    Public Shared Function GetSplitHangul(ByVal HanChar As Char, ByRef cho As Char, ByRef jung As Char, ByRef jong As Char) As Integer
        Dim num As Integer = AscW(HanChar)
        cho = ChrW(0)
        jung = ChrW(0)
        jong = ChrW(0)
        If (MyString.IsHangul(HanChar) <> E_Hangle.완성형) Then
            Return -1
        End If
        num = (num - &HAC00)
        Dim index As Integer = CInt(Math.Round(Conversion.Int(CDbl((CDbl(num) / 588)))))
        num = (num Mod &H24C)
        Dim num5 As Integer = CInt(Math.Round(Conversion.Int(CDbl((CDbl(num) / 28)))))
        Dim num4 As Integer = (num Mod &H1C)
        If (((index > &H12) Or (num5 > 20)) Or (num4 > &H1B)) Then
            Return -1
        End If
        cho = MyString.ChoSung(index)
        jung = MyString.JungSung(num5)
        jong = MyString.JongSung(num4)
        Return IIf(jong = ChrW(0), 0, 1)
    End Function

    Public Shared Function IsHangul(ByVal c As Char) As E_Hangle
        Dim num As Integer = AscW(c)
        Dim num2 As Integer = num
        If ((num2 >= &H1100) AndAlso (num2 <= &H1159)) Then
            Return E_Hangle.초성
        End If
        If ((num2 >= &H1161) AndAlso (num2 <= &H11A2)) Then
            Return E_Hangle.중성
        End If
        If ((num2 >= &H11A7) AndAlso (num2 <= &H11F9)) Then
            Return E_Hangle.종성
        End If
        If ((num2 >= &H3130) AndAlso (num2 <= &H318F)) Then
            Return E_Hangle.자모
        End If
        If ((num2 >= &HAC00) AndAlso (num2 <= &HD7AF)) Then
            Return E_Hangle.완성형
        End If
        Return E_Hangle.한글아님
    End Function



    Public Shared Function GetOrgString(ByVal src As String, Optional ByVal Exp As Boolean = False, Optional ByVal UseOriginal As Boolean = False) As String
        If UseOriginal Then Return src
        If src = "" Then Return ""
        Dim retstr As New System.Text.StringBuilder
        Dim ascnum As Integer
        For Each C As Char In src.ToCharArray
            ascnum = Asc(C)
            '  MsgBox(C, MsgBoxStyle.Information, ascnum)
            If Exp = True AndAlso (C = "-" OrElse ascnum = 40 OrElse ascnum = 91) Then '// ( 나 [를 발견하면 그대로 빠진다.
                Exit For
            End If
            If ascnum < 0 OrElse ascnum > 127 OrElse (ascnum > 47 AndAlso ascnum < 58) OrElse (ascnum > 64 AndAlso ascnum < 91) OrElse (ascnum > 96 AndAlso ascnum < 123) Then
                retstr.Append(C)
            End If
        Next
        Return retstr.ToString
    End Function












End Class
