URL Decoding

Sep 5, 2007

CREATE FUNCTION dbo.fnDeURL
(
@URL VARCHAR(8000)
)
RETURNS VARCHAR(8000)
AS
BEGIN
DECLARE @Position INT,
@Base CHAR(16),
@High TINYINT,
@Low TINYINT,
@Pattern CHAR(21)

SELECT@Base = '0123456789abcdef',
@Pattern = '%[%][0-9a-f][0-9a-f]%',
@Position = PATINDEX(@Pattern, @URL)

WHILE @Position > 0
SELECT@High = CHARINDEX(SUBSTRING(@URL, @Position + 1, 1), @Base),
@Low = CHARINDEX(SUBSTRING(@URL, @Position + 2, 1), @Base),
@URL = STUFF(@URL, @Position, 3, CHAR(16 * @High + @Low - 17)),
@Position = PATINDEX(@Pattern, @URL)

RETURNREPLACE(@URL, '+', ' ')
END
E 12°55'05.25"
N 56°04'39.16"

EDIT: Decoding + as Jeff mentioned

View 9 Replies


ADVERTISEMENT

Decoding Days Bitwise AND

Nov 11, 2004

Hello All

I'm working on a recurring multi-day appointment program. Basically the user can choose a meeting on multiple days of the week over a span of time. For example: Tuesday and Thursday from 10:00 to 10:30 from December 1st 2004 to February 27th 2005.

So I've decided the best way to handle this is to assign a value to each day of the week like so:
MON = 1
TUE = 2
WED = 4
THU = 8
FRI = 16
SAT = 32
SUN = 64

So if the user picks TUE and THU that would be 2 + 8 = 10. The value is unique and seems to work.

So the values would be:
@begin_date = '12/01/2004'
@begin_time = '10:00 AM'
@end_date = '02/27/2005'
@end_time = '10:30 AM'
@recur_days = 10

Now I want to pass the values to stored procedure that will decode the recur_days variable and create entries in a table for each date. I'm struggling to figure out 2 things

1. How do I decode the 10 back into 2(TUE) + 8(THU) ( I think it has something to do with the bitwise AND "&" operator but I'm not sure how to use it.)

2. What is the best way to loop through the date range and create a record for each day?

Regards
Russ

View 2 Replies View Related

Decoding MIME Base64

May 18, 2006

Hi

How do you decode an image (found inside an xml file) which has been encoded in MIME Base 64. If you read in the string, how would you get the image?

I know other database systems (like ASA) that has a build in function to do it for you but I cant find a similar function in SQL Express?

Thanks

View 1 Replies View Related

Decoding A Binary Base64 Inside A XML Using Transact SQL

Feb 16, 2004

Yes i just can't find a place to help me out on something.

Everything went well to create the XML using transact SQL command

SELECT TOP 10 * FROM TblEvenement for xml auto, binary base64


But how do decode my image field in my XML so i can save the data into a new table ..


all this as to be done in a store procedure inside SQL-Server 2000 !!


thanx guys !!


***Any good sites or example i can use for !!

View 5 Replies View Related

Decoding Decimal Form Of HRESULT From ErrorCode

Mar 2, 2006

I have an OLE-DB Command transformation that inserts a row. If the insert SQL command fails for some reason, I use the "Redirect Row" option to send the row to another OLE-DB Command transformation that logs the error on that row to a "failed rows" table. In this table I log the ErrorCode and ErrorColumn values that come with the error path from the first OLE-DB Command.

OK, that's all working great. However, here's the kicker: there's no error description value. The ErrorCode value, naturally, is the decimal form of an HRESULT--for example, -1071607696. Without some further information, however, this code is not useful for troubleshooting.

Has anyone figured out a trick here? I'm not even certain that this is an SSIS HRESULT, since it could for all I know be from the OLE-DB layer, the database layer, or somewhere else.

Thanks,
Dan

View 7 Replies View Related

NText Column Text Encoding/decoding

Sep 19, 2007

Hi,

I have a table column type as nText, however there are some Chinese character stored in that field and it is a messed up as it is not readable.

In my vb.net code, I did Convert to unicode by getting the byte of each character and encode it with UTF8 e.g:


Public Shared Function ConvertToUnicode(ByVal s As String) As String


' Convert To Unicode

Dim MyBytes As Byte() = Encoding.Default.GetBytes(s)

Dim GBencoding As Encoding = System.Text.UTF8Encoding.UTF8

Return GBencoding.GetString(MyBytes)

End Function


This works well but ,the problem is that it slows down the process quite alot, and I wonder are there any text encoding method I can use in SQL that can run when i do the SELECT Statement?


SELECT
Convert(MyNTEXTColumn)
....
something like that?

Thanks.
Jon

View 4 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved