473,657 Members | 2,661 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Function to remove accent in string

Hi,

Does anyone have a function which replaces accent chars from a string
with the non-accented equivalent? For example 'hôpital' should return
'hopital'.

Thank you in advance.
Jul 20 '05 #1
3 21802
Is this so that you can compare differently accented strings? If so and if
you are using SQL2000 then there is no need actually to replace the accented
characters. Just use an accent-insensitive collation for your comparisons:

IF 'hôpital'='hopi tal' COLLATE Latin1_General_ CI_AI
PRINT 'YES'

This avoids an expensive update. Better still, if you can change the column
collation to be accent-insensitive then you can create an index on the
column to help with the comparison.

Otherwise you could replace the accented chars like this:

UPDATE YourTable SET col =
REPLACE(REPLACE (REPLACE(REPLAC E(REPLACE(REPLA CE(
REPLACE(REPLACE (REPLACE(REPLAC E(REPLACE(REPLA CE(
REPLACE(REPLACE (REPLACE(REPLAC E(REPLACE(REPLA CE(
REPLACE(REPLACE (REPLACE(REPLAC E(REPLACE(REPLA CE(
REPLACE(REPLACE (col COLLATE Latin1_General_ CI_AI
,'a','a'),'b',' b'),'c','c'),'d ','d'),'e','e') ,'f','f')
,'g','g'),'h',' h'),'i','i'),'j ','j'),'k','k') ,'l','l')
,'m','m'),'n',' n'),'o','o'),'p ','p'),'q','q') ,'r','r')
,'s','s'),'t',' t'),'u','u'),'v ','v'),'w','w') ,'x','x')
,'y','y'),'z',' z')

Again, this assumes you are using 2000. If correct case is important to you
then specify a case-sensitive collation in place of Latin1_General_ CI_AI and
add nested REPLACE statements for all the upper-case letters too.

--
David Portas
SQL Server MVP
--
Jul 20 '05 #2
Thanks David.

I tried changeing the column to be accent-insensitive as you suggest
and indeed it does work when using a simple SQL statement with a WHERE
clause (WHERE 'hôpital'='hopi tal'). However, I am using freetext
search on this column and when I use CONTAINSTABLE there is no result
found for 'hopital' it only works for 'hôpital'. Do you have any ideas
how I can get this to work without using a replace function?

Darren.

"David Portas" <RE************ *************** *@acm.org> wrote in message news:<pr******* *************@g iganews.com>...
Is this so that you can compare differently accented strings? If so and if
you are using SQL2000 then there is no need actually to replace the accented
characters. Just use an accent-insensitive collation for your comparisons:

IF 'hôpital'='hopi tal' COLLATE Latin1_General_ CI_AI
PRINT 'YES'

This avoids an expensive update. Better still, if you can change the column
collation to be accent-insensitive then you can create an index on the
column to help with the comparison.

Otherwise you could replace the accented chars like this:

UPDATE YourTable SET col =
REPLACE(REPLACE (REPLACE(REPLAC E(REPLACE(REPLA CE(
REPLACE(REPLACE (REPLACE(REPLAC E(REPLACE(REPLA CE(
REPLACE(REPLACE (REPLACE(REPLAC E(REPLACE(REPLA CE(
REPLACE(REPLACE (REPLACE(REPLAC E(REPLACE(REPLA CE(
REPLACE(REPLACE (col COLLATE Latin1_General_ CI_AI
,'a','a'),'b',' b'),'c','c'),'d ','d'),'e','e') ,'f','f')
,'g','g'),'h',' h'),'i','i'),'j ','j'),'k','k') ,'l','l')
,'m','m'),'n',' n'),'o','o'),'p ','p'),'q','q') ,'r','r')
,'s','s'),'t',' t'),'u','u'),'v ','v'),'w','w') ,'x','x')
,'y','y'),'z',' z')

Again, this assumes you are using 2000. If correct case is important to you
then specify a case-sensitive collation in place of Latin1_General_ CI_AI and
add nested REPLACE statements for all the upper-case letters too.

Jul 20 '05 #3
I'm not an expert with Full Text but see this thread:
http://www.google.com/groups?hl=en&l...TNGP12.phx.gbl

--
David Portas
SQL Server MVP
--
Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
14879
by: JB | last post by:
Hi, I'm having a problem with accent in PHP/HTML. I have a value stored in a table. The value is : é è à ù When I look directly into table via phpmyadmin, the value seems to be stored correctly. Yet, when I try to get the value in my php code (mysql_query() ... ), what I get is totally different for the three lasts characters.
114
7699
by: muldoon | last post by:
Americans consider having a "British accent" a sign of sophistication and high intelligence. Many companies hire salespersons from Britain to represent their products,etc. Question: When the British hear an "American accent," does it sound unsophisticated and dumb? Be blunt. We Americans need to know. Should we try to change the way we speak? Are there certain words that sound particularly goofy? Please help us with your advice on this...
0
1189
by: ucasesoftware | last post by:
I send some sms in my Win app. but i have trouble with accent accènts = accAent for example when i receive my sms :( if i request the url directly in IE all accent are fine... so it's this code here who is not like "Iso ???". Someone can help pls ? Dim myReg As Net.HttpWebRequest = _ DirectCast(Net.WebRequest.Create("http://www.tesUrl.com?numero=0623262632&message=à%20la%20clére%20fontène,%20lé%20accènts%20pàssent%20bien"), _
1
1973
by: Fabrice | last post by:
Hello, I have encountered a deep problem with accent and I don't understand why. I m preparing a multi-language website. French and English so far. With french, we have accents and ... problems ;-) The internationalisation of my website works like that : - I have created a resources file for a language (french for example) by using Resgen Command.
2
2287
by: Ramon | last post by:
Hello, How to pass parameter with acute accent to xsltproc ? example : (été (french) = summer) $ xsltproc --stringparam ch été fichier.xsl fichier.xml It is written in the xsltproc man that the string --stringparam must be in utf-8
11
14873
by: cody | last post by:
Is there a method to replace special characters like Ä (A-Umlaut) with A, Ö (O-Umlaut) with O, and so on? Sure, I could look for each character separately and replace it with its ascii-counterpart, but there are also such special characters in French and Swedish and many other languages which I also want to catch. Is there a generic way to do it?
7
1870
by: John Devlon | last post by:
Hi, Can anyone please help me? I've wrote a small application that reads the content from a text-file. Some characters are not displayed correcly. I noticed the text-file uses different types of Accent Signs ('). Is there some simple methode to replace all of them to just one kind ?
2
4410
by: verb13 | last post by:
I am running this query to an sql server 2000 database from my asp code: "select * from MyTable where MySqlServerRemoveStressFunction(MyNtextColumn) = '" & MyAdoRemoveStressFunction(MyString) & "'" The problem is that the replace function doesn't work with the ntext datatype (so as to replace the stresses with an empty string). I had to implement the MySqlServerRemoveStressFunction, i.e. a function that takes a column name as a...
4
9909
by: MC | last post by:
Is there a string function in .NET that will remove the accent marks from letters? I know that's a slightly vague request... and that I could implement it by table lookup (and will do so unless something's already there). But can it be accomplished by switching a string among "cultures" or something like that?
0
8319
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8837
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8739
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8512
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8612
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5638
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4171
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4329
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1969
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.