In my database i had one column as name, where in this column it has name of all recipe names with english and french character.
When i search a string like query:
Select recipe.name from recipe_table where name LIKE = %crepe%
it gives me no result. But it should return one result this-"crèpes"
So i need: search through english alphabet and give me result of all english + french alphabet , it means all result.
thank you in advance .
Instead of searching Spanish character I had created one more column as name2 where i convert all Spanish name to English name.
And then I search English characters from column name2.
First of all I think that the encoding of the database must be UTF-8.
Then:
Select recipe.name from recipe_table where name LIKE = %crepe%
will find any values that have 'crepe' in any position, and you need 'crèpe'.
Possibly you can change french characters by _ .
Select recipe.name from recipe_table where name LIKE = %cr_pe%
But I'm not sure.
Also there are some solutions:
1) Try to search how to rebuild android's sqlite with icu support.
2) Or use custom cursor wrapper like this
Related
I have a .txt file which contains above 1000 words
sample city names below
Razvilka
Moscow
Firozpur Jhirka
Kathmandu
Kiev
Pokhara
Merida
Delhi
Reshetnikovo
Ciudad Bolivar
Marfino
Zhukovskiy
Reutov
Kurovskoye
etc
I would like to have these words in this format below
"Razvilka","Moscow","etc","etc"
enclosed with double quotation and with a comma in the end.I am using Notepad++.Could you mention how to do it and which software should I use it?
If you're using Notepad++, make a Search and Replace replacing
\b(\w+)\b
with
"$1",
It'll find all words and replace with them self, surrounded by quotes. You'll have to manually remove the last , if that's unwanted.
Regards
I wonder if this question is about programming, but You tagged android, regex and android studio, so I guess it is. If yes, You can simply split a string in that way:
String[] splitted = yourString.split("\\s+");
In that case, You are splitting the strings by whitespaces (this regex is also for more than one whitespace), like Your string seems to be. If You have more than one delimiter, You can do it by using the OR operator |
String[]splitted = yourString.split("-|\\.");
In that example, You are splitting the String by - and . (minus and point). The delimiter is the sign where the String is splitted by.
I am coding a dictionary project. Its can translate english to arabic or arabic to english. Words are stored in sqlite fts4 database.
Arabic letter in database stored html encoded like
غير
When i use fts4 query syntax in english to arabic for example => stor
SELECT * FROM fts_dic WHERE english MATCH '"^stor*"';
Returned results are good for me like
store
stored
storage
But when i search arabic to english for => غير
SELECT * FROM fts_dic WHERE english MATCH '"^غير*"';
Returned results
ظغير
֎غيرظ
But i want to see result only start with my searched html encoded text like
غيرخ
غيرٗ
I use "^" at the begining of the word to get this result as you see. In english to arabic works fine but arabic to english not working properly.
The FTS documentation says:
A term is a contiguous sequence of eligible characters, where eligible characters are all alphanumeric characters and all characters with Unicode codepoint values greater than or equal to 128. All other characters are discarded when splitting a document into terms. Their only contribution is to separate adjacent terms.
In other words, punctuation characters like &#; are completely ignored; what FTS sees are the three words 1594, 1610, and 1585.
In the FTS table, you should not HTML-encode anything; just use the plain Unicode characters.
Furthermore, ^ works only in FTS4 tables (which may not be available in all Android versions).
Looking on input types that a EditText view can have i seen "textPersonName" and i try to search a way to (if possible) split name and surname using maybe a method like editText.getName. My question is exist a method of edittext that splits name and surname in edittext? And if don't exist the best way is to use split or else?
The textPersonName is just a style option, for instance it capitalizes the first letter of each word. It won't help you distinguish first and last names. However you can search for spaces, for instance:
String[] names = editText.getText().toString().split(" ");
The Array of Strings will have each name in a different String. If the user entered: John Doe you would have "John" in names[0] and "Doe" in names[1].
Hello friends I have made an application in which I have fetched data from database.All data in my application is coming from database.I have made this application in English language but now I want to convert my application in Hindi and other languages too.Actually if I used XML for string then I make different string.xml for every language and then set locale it was not the issue but converting string in database and then fetch.so please suggest me how can I adopt this idea.Any help would be appreciable.
You can either:
Add columns to your tables with the translations:
TABLE messages : ID, CONTENT, CONTENT_FR, CONTENT_ES, ...
Then you select the column according to the locale set in the device (if locale is FR, then use the column CONTENT_FR, if the locale is something not yet provided by the app, fallback to the CONTENT column)
Use several DB files (if your DB is static and won't be updated):
Load the DB file that corresponds to the user locale. Then your queries will remain unchanged.
You can also have db like
id, type, lang_id, str
id - string id
type - where this is used (1-login message, 2-error message, 3-character names, 4-attack names, etc.)
lang_id - language id, you can use 2-digit code (EN-English, FR-French, DE-German, etc.) or your own id definition (1-English, 2-French, 3-German, etc.)
str - the display string
How I should write my sql query in android that special characters work correct. For example when I filter String with like which has % symbol, it doesn't work correct.
For LIKE, you choose in the query what to escape them with;
SELECT * FROM Olle WHERE name LIKE 'Many ^% have fallen' ESCAPE '^';
...will only match the actual character % since it's been escaped with the ^ that is give in the ESCAPE clause.
SQLfiddle here.