C# How to replace Microsoft's Smart Quotes with straight quotation marks?

后端 未结 12 1424
花落未央
花落未央 2020-12-08 00:50

My post below asked what the curly quotation marks were and why my app wouldn\'t work with them, my question now is how can I replace them when my program comes across them,

12条回答
  •  南方客
    南方客 (楼主)
    2020-12-08 01:42

    The VB equivalent of what @Matthew wrote:

    Public Module StringExtensions
    
        
        Public Function StripIncompatableQuotes(BadString As String) As String
            If Not String.IsNullOrEmpty(BadString) Then
                Return BadString.Replace(ChrW(&H2018), "'").Replace(ChrW(&H2019), "'").Replace(ChrW(&H201C), """").Replace(ChrW(&H201D), """")
            Else
                Return BadString
            End If
        End Function
    End Module
    

提交回复
热议问题