XHTML Compliance - Microsoft word apostrophe

Posted on 2006-04-03
Last Modified: 2013-12-16
Hi I have a news page updated by a control panel which users just often copy and paste news items from a Microsoft Word document.  I want the output page to be html compliant and have a replace function on the page for the & symbol and a few others.  I cannot find one for the curly apostrophe that comes from the Word Document.

server.htmlencode will not work as i want to be able to include html links in the item.

Question by:harris9999
    LVL 25

    Accepted Solution

    I use the function below to get all HTML tags out of a textarea (or any other form field actually)

    Function rmvHTML(strString)
         Dim nCharPos, sOut, bInTag, sChar
         sOut = ""
         bInTag = False
         For nCharPos = 1 To Len(strString)
              sChar = Mid(strString, nCharPos, 1)
              if sChar = "<" Then
                   bInTag = True
              end if
              if not bInTag Then sOut = sOut & sChar
              if sChar = ">" then
                   bInTag = False
              End if
         rmvHTML = sOut
    End Function

    you could also do something similar to this:
    <script language="JavaScript">
    function Del(Word) {
    a = Word.indexOf("<");
    b = Word.indexOf(">");
    len = Word.length;
    c = Word.substring(0, a);
    if(b == -1)
    b = a;
    d = Word.substring((b + 1), len);
    Word = c + d;
    tagCheck = Word.indexOf("<");
    if(tagCheck != -1)
    Word = Del(Word);
    return Word;
    function Check() {
    ToCheck = document.form.text.value;
    Checked = Del(ToCheck);
    document.form.text.value = Checked;
    alert("This form is not set to submit anywhere so you will stay here.  But please notice that the text box's contents have been \"filtered\".");
    return false;
    // -->
    <center><h1>Removing HTML</h1></center>
    <p>This script is intended to ensure that people do not use HTML tags in form messages, Web forums, and so on. Type some text with HTML tags in the box below to try it out.</p>
    <form name=form onSubmit="return Check()">
    <textarea cols="50" rows="6" name="text"></textarea>
    <input type="submit" value="Submit Entry">
    LVL 3

    Author Comment


    I want to be able to include the html tag in the text area, so that a link could be added if required.  Thats why i can't use, server.htmlencode.  
    I just noticed a typo in my initial message.  i want the output to be xhtml compliant.  
    In the page where it is output i replace the & symbol etc

                      strText = replace(rs.fields("Details"),"&#8217;","'")
                      strText = replace(strText,"&","&amp;")
                      strText = replace(strText,"&#8217;","'")
                      strText = replace(strText,"&rsquo;","'")
                      strText = replace(strText,"‘","'")
                      strText = replace(strText,"&rsquo;","'")

    i have tried to replace the various aprostophe's but i can't get one to replace the apostrophe which is pasted from a word document, and it is this one which breaks the xhtml compliance.
    LVL 3

    Author Comment

    strText = replace(strText, Chr(146),"'")

    This fixed the problem

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Now that Expression Web 4.0 ( is free if you buy or have the full version of Expression Web 3.0, now is the best time to  migrate from FrontPage to Expression Web (http://www.frontpage-to-exp…
    When setting up new project requests for our site, one of the most powerful tools our team has available to use is Axure ( It’s a tool for creating software and web prototypes that can function and interact as if it were the a…
    The purpose of this video is to demonstrate how to make a WordPress Site faster and smaller in size by cleaning up the database. This will be demonstrated using a Windows 8 PC. Plugin WP Optimize will be used. Go to your WordPress login page. T…
    The purpose of this video is to demonstrate how to insert an Iframe into WordPress. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: : Open Page or Post…

    732 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now