OK, I have a process that pulls data from a holding table and posts it into SalesForceDotCom. It works great unless the data has European names including special characters (like grave, umlaut etc.). The post data looks like this
And somebody well before my time wrote a pseudo encode function
which does not seem to work (for the special characters) as the records with the special characters are not making it into SalesForceDotCom. So, I went looking around and found a number of options that people said were their encoding functions, but they did not look like they would actually work with the form of my @post variable, so I am coming to this great forum looking for help in doing this and understanding exactly what is happening.
Thank you for your time and help!
WB
Code:
@post = 'crapvariable=togetridofspace&encoding=' + @encoding + '&first_name=' + @vchFirstName +'&last_name=' + @vchLastName + '&email=' + @vchEmailAddress + '&phone=' + @vchPhoneNumber + '&company=' + @vchCompanyName + '&country=' + @chCountryCode + '&state=' + @chRegionCode + '&oid=' + @oid + '&retURL=' + @retURL + '&lead_source=' + @lead_source + '&mf=' + @migrationforecast + '&pn=' + @vchProduct + '&sfga=' + @sfga + '&cid=' + @campaignid + '&cust=' + @CustomerID + '&sn=' + @vchSerialNumber + '&description=' + @vchDescription + '&crapvariable=togetridofspace',
And somebody well before my time wrote a pseudo encode function
Code:
declare @i int
declare @ch nchar
declare @hex varchar(6)
SET @i = 1
WHILE @i <= datalength(@post)
BEGIN
SET @ch = substring(@post, @i, 1)
IF @ch not in ('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','0','1','2','3','4','5','6','7','8','9','-','_','.','!','~','*',''',(',')','&','=')
BEGIN
if @ch = ' '
BEGIN
-- use alternate RFC1738 encoding -- Spaces are encoded as a "+" not "%20"
set @hex = '+'
END
ELSE
BEGIN
SELECT @hex = ASCII(@ch)
-- converts the number from base10 to base16 (dec to hex)
exec base_convert @hex OUTPUT, 10, 16
SET @hex = lower('%'+@hex)
end
SELECT @post = stuff(@post, @i, 1, @hex)
Select @i = @i + datalength(@hex) - 1
END
set @i = @i + 1
END
which does not seem to work (for the special characters) as the records with the special characters are not making it into SalesForceDotCom. So, I went looking around and found a number of options that people said were their encoding functions, but they did not look like they would actually work with the form of my @post variable, so I am coming to this great forum looking for help in doing this and understanding exactly what is happening.
Thank you for your time and help!
WB