• opc.three (7/1/2013)


    I think you have added an abstraction layer that seems to work but at the end of the day you still have an entitization problem:

    My problem seems to have been more of communication than entitization: I left too much to implication when I said 'do the conversion from "&" -> "&" last'. I should have been clearer about the need to translate the other two encoded values -- < and > -- FIRST. Since there are 3 values that are encoded, those same 3 values need to be decoded. And, it is just as import to encode the & first as it is to decode it last.

    So, to re-run the test:

    DECLARE @Before NVARCHAR(MAX),

    @After NVARCHAR(MAX);

    SET @Before = N'>&>>';

    SET @After = REPLACE(

    CAST(dbo.ShowEntireString(@Before) AS NVARCHAR(MAX)),

    N'&',

    N'&'

    );

    -- not the same, but due to missing a REPLACE on >

    SELECT @Before AS [Before], @After AS [After]

    SET @After =

    REPLACE(

    REPLACE(

    REPLACE(

    CAST(dbo.ShowEntireString(@Before) AS NVARCHAR(MAX)),

    N'>',

    N'>'

    ),

    N'<',

    N'<'

    ),

    N'&amp;',

    N'&'

    );

    -- same values

    SELECT @Before AS [Before], @After AS [After]

    Take care,

    Solomon...

    SQL#https://SQLsharp.com/ ( SQLCLR library ofover 340 Functions and Procedures)
    Sql Quantum Lifthttps://SqlQuantumLift.com/ ( company )
    Sql Quantum Leaphttps://SqlQuantumLeap.com/ ( blog )
    Info sitesCollations     •     Module Signing     •     SQLCLR