Attribute VB_Name = "udf_masked2unicode" '------------------------------------------------------------------------------- 'File : udf_masked2unicode.bas ' Copyright mpl by ERB software ' All rights reserved ' wiki.yaslaw.info/dokuwiki/doku.php/vba/functions/masked2unicode 'Environment : VBA 2007 + 'Version : 1.0.1 'Name : masked2unicode 'Author : Stefan Erb (ERS) 'History : 03.12.2014 - ERS - Creation ' 20.11.2015 - ERS - Kleiner Fehler behoben. Bei "a\\u0057" hat er "\" übersetzt. Das ist behoben '------------------------------------------------------------------------------- Option Explicit '/** ' * Wandelt jedes mit \ maskierte Feld in Unicode um, ausser es handelt sich bereits um einen Unicode ' * @param String ' * @return String ' */ Public Function masked2uniode(ByVal iString As String) As String Static rx As Object If rx Is Nothing Then Set rx = CreateObject("VBScript.RegExp"): rx.pattern = "\\(?!\\?u[0-9A-F]{4})(.)" masked2uniode = iString Do While rx.test(masked2uniode) 'Logik siehe auch http://wiki.yaslaw.info/dokuwiki/doku.php/vba/cast/char2unicode Dim unicode As String: unicode = rx.execute(masked2uniode)(0).subMatches(0) unicode = Hex(AscW(unicode)) 'Hex-Wert ermitteln unicode = "\u" & String(4 - Len(unicode), "0") & unicode masked2uniode = rx.Replace(masked2uniode, unicode) Loop End Function