Need T-SQL UDF to URLEncode non-Ascii characters (i.e. Chinese, Macedonian, etc)

Posted on 2012-09-04
Last Modified: 2012-09-10
We need a function that will properly url encode a string even if it contains non-ascii characters such as chinese language characters for example.

We've tried this already:

Along with this:

And they don't handle non-ascii characters well.  If this can't be done in t-sql can someone post or recommend some good VB.Net or C# code that we can turn into a dll and upload to the db?
Question by:afacts
    LVL 19

    Accepted Solution

    Hi afacts,

    Second function ( should handle unicode characters. Make sure you are passing parameter as NVARCHAR, not VARCHAR. You should put N before string value, like this:

    SELECT dbo.UrlEncode(N'¿¿/¿¿')

    Author Closing Comment

    Thanks Rimvis ... we decided to go a different route in functionality but you're right in that, that function is actually better than the others when used correctly ...

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
    The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
    Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
    This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

    760 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

    7 Experts available now in Live!

    Get 1:1 Help Now