473,385 Members | 1,582 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

In latin1_swedish_ci the backslash character is equal to a-umlaut, how to get around

Has anyone come across a way to get around the
limitation that in the MySQL collation
latin1_swedish_ci the backslash character is
considered equal to a-umlaut?
http://www.collation-charts.org/mysql60/mysql604.latin1_swedish_ci.html

5C=C4=E4

I.e. the following queries result in the same set of rows
when latin1_swedish_ci is in use, those containing either character:

SELECT * FROM products WHERE name LIKE '%\\\\%'

SELECT * FROM products WHERE name LIKE '%Ä%'

I have tried in vain to locate an answer other than transition
to utf8 in the net, since I do not necessarily have the option
of modifying the structure of the database tables or their columns
to utf8.

Thanks in advance for any help,

Hesekiel
Sep 30 '09 #1
6 3360
Regarding the original phrasing of my question:

I must stress the fact that other than the treatment of the backslash character the latin1_swedish_ci collation matches my needs exactly regarding sort order and filtering. My only problem is with the treatment of the backslash character therein.

Hesekiel
Sep 30 '09 #2
Atli
5,058 Expert 4TB
Hey.

I'm not seeing a solution to this if you are unwilling to change the charset.
This is a limitation, which you are subject to if you choose to use this particular charset.

You should really consider changing to Unicode.
Other then using a bit more disk-space (which is cheap, by the way), there is really no downside to using Unicode.
At least none that I can see.

Why not upgrade?
Oct 1 '09 #3
Thanks for responding Atli,

But:

Having experimented in this area for the past week or so, I have come to be under the impression that utf8 (if that is what you refer to by unicode) is _not_ the solution.

To demonstrate:

First create a database:

Expand|Select|Wrap|Line Numbers
  1. CREATE DATABASE `test2swe`
  2. DEFAULT CHARACTER SET utf8 COLLATE utf8_swedish_ci;
  3.  
  4. use test2swe;
  5.  
  6. CREATE TABLE `test2swe`.`t1` (
  7.   `id` INT NOT NULL AUTO_INCREMENT ,
  8.   `c` VARCHAR( 128 ) CHARACTER SET utf8 COLLATE utf8_swedish_ci NOT NULL ,
  9. PRIMARY KEY ( `id` ) 
  10. ) ENGINE = MYISAM
  11.  
  12. INSERT INTO `test2swe`.`t1` (`id` , `c`)
  13. VALUES (NULL , 'foo'),
  14.        (NULL , 'backs\\'),
  15.        (NULL , 'jälkiruoka'),
  16.        (NULL , 'backs\\ash'),
  17.        (NULL , 'bar');
  18.  
Then try the following two queries:

Expand|Select|Wrap|Line Numbers
  1. SELECT c FROM `t1` WHERE `c` LIKE '%ä%';
  2. SELECT c FROM `t1` WHERE `c` LIKE '%Ä%';
  3.  
Both return ==> jälkiruoka

Ok, fine so far.

When we try

Expand|Select|Wrap|Line Numbers
  1. SELECT c FROM `t1` WHERE `c` LIKE '%\\\\%';
  2.  
We get an empty resultset because (I think)
http://www.collation-charts.org/mysq...wedish_ci.html
doesn't include the backslash character and it is thus left out.

When trying out

Expand|Select|Wrap|Line Numbers
  1. SELECT c FROM `t1` WHERE `c` LIKE '%\\\\%' COLLATE utf8_general_ci;
  2.  
we get both 'backs\' and 'backs\ash' in the resultset.

But if we try the same:

Expand|Select|Wrap|Line Numbers
  1. SELECT c FROM `t1` WHERE `c` LIKE '%ä%' COLLATE utf8_general_ci;
  2.  
We get the results backs\,backs\ash,bar and ,jälkiruoka

Everythin with an a in it because in

http://www.collation-charts.org/mysq....european.html

ä = a

To summarize: utf8 does not seem to be of much help to me.

The problem is that I have a db with potentially 100 000+ entries,
the product names of which may contain just about anything and
be searchable via user-inputed text (i.e. '%usertexthere%').

What would you Atli and the other experts out there suggest I adopt
as my approach to this problem?

Sincerely,

Hesekiel
Oct 1 '09 #4
Sorry about partially directing my question to the moderator who had replied to me in the final portion of my previous message.

Inadvertedly ignored posting guidelines,

Hesekiel
Oct 1 '09 #5
corr: Inadvertently

/Hesekiel
Oct 1 '09 #6
To summarize: I am looking for a solution which would act in all respects (sort order etc.) like the latin1_swedish_ci but for the treatment of the backslash character. MySQL being one of the most used databases one would expect such a solution to exist or have been invented by someone.

After all, for example: Windows pathnames may be stored in databases, contain backslashes, nowadays may contain strange characters and anything stored in a database may and will be searched for. So I think this is an issue of wider interrest.

Hesekiel, still looking into collations and everything possible
Oct 2 '09 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Aloysio Figueiredo | last post by:
I need to replace every ocurrence of '/' in s by '\/' in order to create a file named s. My first attempt was: s = '\/'.join(s.split('/')) but it doesn't work: >>> s = 'a/b' >>> s =...
5
by: Ladvánszky Károly | last post by:
What is the correct way to match/search a backslash with regular expressions? print re.match('\\m', '\\m').group(0) raises an error while print re.search('\\m', '\\m').group(0) yields 'm' ...
3
by: Vincent Texier | last post by:
Hello, I want to send 3 chars in hexa code to the serial port. So I type in a tkinter entry : "\x20\x01\x21" The string is set in a StringVar(). When I read the stringVar, I get :...
1
by: Grant Allen | last post by:
I know this has been asked before - I've trawled through the mail archives and FAQs looking for any info, and only found "that's the way it works" answers. Basically, I want to turn off backslash...
3
by: Sathyaish | last post by:
In trying to replace character literals for their char constant, I am having difficulty printing the char constant for backslash. It instead prints the char literal. How do I resovle this? ...
19
by: Alan J. Flavell | last post by:
The story so far: on somewhat unrelated newsgroup, my attention fell upon the URL: http://www.speedtouchdsl.com/prod706.htm which contains a link to the purported URL:...
8
by: Wijaya Edward | last post by:
Hi all, I was trying to split a string that represent chinese characters below: ??? But why the split function here doesn't seem
44
by: Kulgan | last post by:
Hi I am struggling to find definitive information on how IE 5.5, 6 and 7 handle character input (I am happy with the display of text). I have two main questions: 1. Does IE automaticall...
3
by: Stef Mientki | last post by:
It looks like sometimes a single backslash is replaced by a double backslash, but sometimes it's not ??? See the error message below, the first backslash is somewhere (not explicitly in my code)...
5
by: vlsidesign | last post by:
The printf function returns "warning: unknown escape sequence: \040" for a backslash-space combination. If the ascii decimal number for space is 32 and the backslash is 92, why this particular...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.