I'm trying to search and replace an invisible unicode control character in a string in TSQL. The control character is 'LSEP' or 0x2028.
I can find the character easily enough using either of these two queries:
SELECT * FROM Email WHERE Html LIKE '%[0x2028]%'
or
SELECT * FROM Email WHERE CHARINDEX(NCHAR(0x2028) COLLATE Latin1_General_BIN2, Html) > 0
However, when I come to try and replace it, the following just doesn't work:
UPDATE Email
SET Html = REPLACE(Html, NCHAR(0x2028) COLLATE Latin1_General_BIN2, '')
WHERE Html LIKE '%[0x2028]%'
Any ideas what I'm doing wrong. I can't use the character itself using N'LSEP', because it just appears as a newline in the script when I try and paste it!
Sample input, as requested:
</span><span>
</span><span>
Try this (it replaces the unicode LSEP with the unicode SPACE char)...
UPDATE Email
SET Html = REPLACE(Html, NCHAR(0x2028), NCHAR(0x0020))
WHERE Html LIKE '%[0x2028]%'
Related
I want to create a Full Text Search that accepts emojis on the query, or another type of index to search on text. For example, I have this text: Playa 🌊🌞🌴 #CobolIquique h' and PostgreSQL parse it weirdly on the emojis.
Debugging, Using SELECT * FROM ts_debug('english','Playa 🌊🌞🌴 #CobolIquique h'); I have the following result:
And I don't know why the token is considered an space symbol. If I debug the parser SELECT * FROM ts_parse('default', 'Playa 🌊🌞🌴 #CobolIquique h'); I just get the same tokens and with the tokens types ts_token_type('default') there is not a emoji type (or something similar). So, How can I create a parser to split the string correctly with the spaces and doesn't consider emojis as blank spaces? or How can I create a text index that can use emojis on the queries?
To create a new parser, which is different from default one, you should be a C programmer and you should write your own PostgreSQL extension. This extension should define the following functions:
start_function();
gettoken_function();
end_function();
lextypes_function();
headline_function(); // optional
As an example you can examine pg_tsparser module.
I have a table that for some reason stores text as IMAGE. I can grab the data and read it using
SELECT CONVERT(NVARCHAR(MAX), CONVERT(VARBINARY(MAX), column,2)) FROM table
Now I need to insert data back in to the table. I've tried
SELECT CONVERT(IMAGE, CAST('TEST TEXT' AS VARBINARY(MAX)))
But when I test converting it back using
SELECT CONVERT(NVARCHAR(MAX), CONVERT(VARBINARY(MAX), CONVERT(IMAGE, CAST('TEST TEXT' AS VARBINARY(MAX))),2))
It returns 䕔呓吠塅 which is obviously not right as it should return "TEST TEXT"
What am I doing wrong here?
The text you're trying to store is encoded as binary ASCII characters. You're trying to convert it back into a Unicode text string, which isn't what it originally was, therefore you're getting back garbled text.
Change your source text string into a Unicode string by adding N in front of it:
SELECT CONVERT(NVARCHAR(MAX), CONVERT(VARBINARY(MAX), CONVERT(IMAGE, CAST(N'TEST TEXT' AS VARBINARY(MAX))),2))
It should return the correct text. Tested this on SQL Server 2008
You can use this one:
SELECT CONVERT(**VARCHAR(MAX)**, CONVERT(VARBINARY(MAX), **CAST('TEST TEXT' AS IMAGE)**,**0**))
Basically, you were not consistent with your character type conversions. In some parts you used NVarChar and some parts Varchar. Also, the number 2 at the end is affecting the result. In you Convert statements, when you don't specify the code, default value (0) is used. So if you are converting it back, you should use the same code.
I am using API to get data from CMS, we are displaying text what user has entered into CMS,
But my problem is when user enter some special character into CMS,I am not able to get those text on iphone side
Here is the link of text what user has entered in wall description
We are using json web service, they are encode string to utf-8 so my json string will be
The word 'stop' isn\u0092t in your vocabulary. Run a marathon in 4.5 hours or less.
The utf character \u0092 is a special character we need to display same in shown in above image
NOTE:
1)if we pass string without encoding to utf-8 in webservice,I am getting whole string as null .
2)I have try with [NSString stringWithCString:[textFromCms cStringUsingEncoding:NSISOLatin1StringEncoding] encoding:NSUTF8StringEncoding];
where textFromCms is text I got from cms as show above.
3)I also try without any conversation/encoding ….it ignore the special character
4)also try with base64 but did not help that also.
Any help would be so appreciated.
The CMS apparently uses windows-1252, not UTF-8. The curly apostrophe is 92 (hex) in windows-1252, U+2019 in Unicode, so when properly encoded into JSON, it should be \2019.
I am using a Zend_Form subclass to add and edit records in a database. The layout has iso-8859-1 encoding and charset. The table records use latin1_spanish_ci collation.
The form input text element doesn't display anything at all when the record contains special characters like accents. If there are no special characters the form input text element displays the record correctly. Curiously enough the special characters display correctly when they appear outside the text input field, for example inside an Html heading2 or a paragraph.
I have tried inserting the following in application.ini:
resources.db.params.charset=iso-8859-1
but I get an error message:
SQLSTATE[42000] [1115] Unknown character set: 'iso-8859-1'
I have also tried changing the db charset to utf8 in the same way. The form text element displays the string but I get strange characters instead of the original ones.
I have tried almost anything but I haven't solved the problem. It seems that text input elements generated with Zend_Form hate Latin characters.
Have you had the same problem?
I found this simple solution in a zf forum:
Add the following to your _initView function in bootstrap.php and forget about everything else:
$view->setEncoding('iso-8859-1');
I have text in a option (using a select tag) that has multiple spaces. These spaces are then converted into one space. I then tried to escape the spaces with but it then converts it to:
&nbsp;
which is not what I want. Is there anyway to disable escaping in Strut2 or have it always escape spaces for me for select tags? There is a way to turn off escapes for property tags but nothing for select, that I can see.
Try with attributes escape=false or escapeAmp=false