wiki.php 用Markdown写wiki是一种什么样的体验?

解码Unicode编码字符.md

最后更新于 2019-10-06 15:00:33

解码Unicode编码字符,如将“==\u82f9\u679c==”解码为“==苹果==”。

Imports System.Text.RegularExpressions

Public Class Form1

    Private Shared Function deChar(ByVal m As Match) As String
        Dim s As String = m.Groups(1).Value
        Dim i As Integer = Convert.ToInt32(s, 16)
        Return ChrW(i).ToString
    End Function
    Shared Function deUniText(ByVal ucode As String) As String
        Return Regex.Replace(ucode, "\\u([a-zA-Z0-9]{4})", AddressOf deChar, RegexOptions.IgnoreCase)
    End Function

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim s As String = "This is \u82f9\u679c."
        MsgBox(deUniText(s))
    End Sub

End Class