Microsoft KB Archive/925847

From BetaArchive Wiki
< Microsoft KB Archive
Revision as of 14:18, 21 July 2020 by X010 (talk | contribs) (Text replacement - "&" to "&")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Knowledge Base


Japanese characters are encoded with an escaped reference when you switch to HTML view after you save Japanese characters in the HTMLPlaceholder control in Content Management Server 2002 SP2

Article ID: 925847

Article Last Modified on 10/26/2007



APPLIES TO

  • Microsoft Content Management Server 2002 Service Pack 2



SYMPTOMS

You install Microsoft Content Management Server (MCMS) 2002 Service Pack 2. When you switch to HTML view after you save Japanese characters in the HTMLPlaceholder control, you notice that the Japanese characters are encoded with an escaped reference. For example, you may see an escaped reference, such as &#12345.

WORKAROUND

To work around this problem, follow these steps:

  1. Create a Microsoft Visual Basic Scripting Edition (VBScript) file that is named ActiveXToolbarHooks.vbs and that has the following code.

    On Error Resume Next
    
    Dim previousEditingSourceState
    previousEditingSourceState = false
    
    Call EnableCompatibleToolbarHooks
    
    Sub OnToolbarInitialize( ByVal pToolbarInterface )
        ' No action required
    End Sub
    
    Sub OnToolbarStateInitialize( ByVal strPlaceholderName, ByVal pState )
        ' No action required
    End Sub
    
    Sub OnToolbarUpdate( ByVal pActiveHtmlEditor, ByVal bEditingSource )
        ' If switching from typical view to HTML source 
    ‘ editing then perform a special decode operation
        If (Not previousEditingSourceState) And bEditingSource Then
            pActiveHtmlEditor.dom.body.innerHtml = 
    DecodeUnicodeChars(pActiveHtmlEditor.dom.body.innerHtml)
        Else
        End If
        previousEditingSourceState = bEditingSource
    End Sub
    
    Sub OnToolbarEvent( Byval pActiveHtmlEditor, ByVal bstrId, 
    ByVal pItem, ByVal bEditingSource )
        ' No action required
    End Sub
    
    Function DecodeUnicodeChars(inputHTML)
    
        Dim charEntityRegExp
        Set charEntityRegExp = New RegExp
        charEntityRegExp.Pattern = "&#(\d{1,5});"
    
        charEntityRegExp.Multiline = True
        charEntityRegExp.Global = True
        charEntityRegExp.IgnoreCase = True
    
        Dim outputHtml
        outputHtml = inputHtml      
    
        outputHtml = charEntityRegExp.Replace(outputHtml, GetRef("DecodeMatchedChar"))
    
        Set charEntityRegExp = Nothing
    
        DecodeUnicodeChars = outputHtml     
    End Function
    
    Function DecodeMatchedChar(fullMatch, subMatch, position, sourceString)  
        DecodeMatchedChar = ChrW(subMatch)
    End Function  
  2. Copy the ActiveXToolbarHooks.vbs file to the MCMS server location that is available by a virtual path. For example, you may copy the file to the MCMS project directory.
  3. Add the following code to every active server page (ASPX) template file in the MCMS project. Alternatively, you may add the following code to DefaultConsole.aspx file and then add the user control to all ASPX template files.

    <cms:AuthoringModeContainer mode="Both" runat="server" id="UnicodeHtmlFixup">
    <script language="vbscript" type="text/vbscript" src="/<cmsproject>/ActiveXToolbarHooks.vbs"></script>
    </cms:AuthoringModeContainer>

    Notes

    • <cmsproject> is a placeholder for the relative path of the ActiveXToolbarHooks.vbs file.
    • Make sure that you use the following MCMS tag prefix:

      <%@ Register TagPrefix="Cms" Namespace="Microsoft.ContentManagement.WebControls" 
      Assembly="Microsoft.ContentManagement.WebControls" %>
    • After you complete these steps, the encoded Japanese characters will be decoded in the HTML view when you save a posting.


Keywords: kbqfe kbprb KB925847