그래서 ASP.Net (vb.net) 응용 프로그램이 있습니다. 텍스트 상자가 있고 사용자가 Microsoft Word의 텍스트를 텍스트 상자에 붙여 넣습니다. 따라서 긴 대시 (charcode 150)와 같은 것들이 입력으로 전달됩니다. 다른 예는 현명한 따옴표 또는 악센트 부호가있는 문자입니다. 내 애플 리케이션에서 나는 그들을 XML로 인코딩하고 SQL 저장 프로 시저에 XML 매개 변수로 데이터베이스에 전달합니다. 사용자가 입력 한대로 데이터베이스에 삽입됩니다.문자 지원 문제 - 높은 ASCII 문자를 낮은 ASCII 문자로 변환하는 방법
문제는이 데이터를 읽는 앱이 이러한 문자를 좋아하지 않는다는 것입니다. 그래서 나는 그것을 낮은 ascii (생각하는 7 비트) 문자 집합으로 변환해야합니다. 어떻게해야합니까? 그들이 어떤 인코딩을하는지 어떻게 결정할 수 있는가? 그래서 나는 다음과 같은 것을 할 수있다. 그리고 ASCII를 동등한 방법으로 요청하거나 코드를 작성해야합니까?
웹 페이지에서이 문제를 쉽게 해결할 수도 있습니다. Word에서 문자 선택을 복사하면 여러 형식이 클립 보드에 저장됩니다. 스트레이트 텍스트 하나는 내가 원하는 것입니다. html 텍스트 상자에 사용자가 붙여 넣을 때 해당 텍스트를 가져 오는 방법이 있습니까? 웹 페이지의 인코딩을 어떻게 든 설정해야합니까?
System.Text.Encoding.ASCII.GetString(System.Text.Encoding.GetEncoding(1251).GetBytes(text))
XML로 입력을 암호화 응용 프로그램에서 코드 :
Protected Function RequestStringItem(_
ByVal strName As System.String) As System.String
Dim strValue As System.String
strValue = Me.Request.Item(strName)
If Not (strValue Is Nothing) Then
RequestStringItem = strValue.Trim()
Else
RequestStringItem = ""
End If
End Function
' I get the input from the textboxes into an array like this
m_arrInsertDesc(intIndex) = RequestStringItem("txtInsertDesc" & strValue)
m_arrInsertFolder(intIndex) = RequestInt32Item("cboInsertFolder" & strValue)
' create xml file for inserts
strmInsertList = New System.IO.MemoryStream()
wrtInsertList = New System.Xml.XmlTextWriter(strmInsertList, System.Text.Encoding.Unicode)
' start document and add root element
wrtInsertList.WriteStartDocument()
wrtInsertList.WriteStartElement("Root")
' cycle through inserts
For intIndex = 0 To m_intInsertCount - 1
' if there is an insert description
If m_arrInsertDesc(intIndex).Length > 0 Then
' if the insert description is of the appropriate length
If m_arrInsertDesc(intIndex).Length <= 96 Then
' add element to xml
wrtInsertList.WriteStartElement("Insert")
wrtInsertList.WriteAttributeString("insertdesc", m_arrInsertDesc(intIndex))
wrtInsertList.WriteAttributeString("insertfolder", m_arrInsertFolder(intIndex).ToString())
wrtInsertList.WriteEndElement()
' if insert description is too long
Else
m_strError = "ERROR: INSERT DESCRIPTION TOO LONG"
Exit Function
End If
End If
Next
' close root element and document
wrtInsertList.WriteEndElement()
wrtInsertList.WriteEndDocument()
wrtInsertList.Close()
' when I add the xml as a parameter to the stored procedure I do this
cmdAddRequest.Parameters.Add("@insert_list", OdbcType.NText).Value = System.Text.Encoding.Unicode.GetString(strmInsertList.ToArray())
이것은 내가 입력하는 것입니다. 이것은 "funny"문자가있는 일부 텍스트입니다. 이것은 출력으로 원하는 것입니다. 이것은 "재미있는"문자가 포함 된 일부 텍스트입니다 (예 : ÃÃÃúññºº¿¿¿Â ¿              ¿ –