I am working on an Arabic-French lexicon.
https://lexique-arabe.org
Using the latest version of Codeigniter (3.1.10).
I haven't a problem to save and view Arabic characters, AJAX requests for Arabic characters work fine.
But, I try to create mixed slug for an Arabic-French lexicon.
For example I need to create
lexique-arabe.org/lexique/amour-محبة (this link doesn't exist yet.)
I use url_title to generate the slug
Helper
function setSlug($string){
$string = convert_accented_characters($string);
return url_title($string, 'dash', true);
}
Controller
$string = $mot->fr.' '.$mot->ar;
$slug = $this->db_utils_lib->stripAccents(setSlug($string));
Result in the database for the field slug :
amour-????????
The ???????? should be the Arabic characters.
If you check the website, you can see that there is no problem with the Arabic characters to save are in the database.
I think there is a problem with config or url_title function
My database config
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
Some config
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-';
Can someone help me?
Thanks
Patrice
Make sure your database encoding accept arabic.
Using SQL and database management tool. Try create a table with text column.
Try to insert Arabic text into the database.
Make sure the text is stored as Arabic.
Try different database clients to see the Arabic text data. Sometime the data is correct but the client/browser/GUI fails to render the correct encoding.
Or simply the client/browser/GUI is missing the correct font.
Related
I have create files for english and german language statically in laravel rscources/lang/en and resources/lang/de folders. i want to change the string of particular lang key using my controller. how i can do ??
Example in resources/lang/en/custom.php
'my_key' => 'My key'
Example in blade:
__('custom.my_key')
or
#lang('custom.my_key')
After much testing and searching, I can not find the solution.
My problem is that I have, for example the route '/services', '/servicios' in spanish.
If my website is in english, all texts are correctly shown in english, same in spanish. But the problem is with the text links, only appear in default locale.
In routes/web.php:
Route::get(trans('rutas.servicios'), 'ServiceController#index')->name('servicios')
File lang/es/rutas.php:
return [
'servicios' => '/servicios',
];
File lang/en/rutas.php:
return [
'servicios' => '/services',
];
and link html:
#lang('menus.servicios')
My goal is to use translated urls without using laravel prefix. That is to say:
https://www.myweb.com/services ~ english
https://www.myweb.com/servicios ~ spanish
share the same Route controller.
Any help? Lot of thanks for your time!
EDIT WITH SOLUTION:
I discovered that laravel performs route mapping before selecting the language. So what I did was to set the language before this, but the session and cookies variables load after this. But I finally discovered that the cached variables satisfied my needs.
At the top of function map() of RouteServiceProvider.php:
App::setLocale(Cache::get('locale'));
To store the selected locale:
Cache::put('locale', $locale, $minutes);
I am having issues displaying data from MySQL in datatables(.net) containing Norwegian characters (Æ, Ø, Å, etc.). I'm running CodeIgniter and have the following variables configured in database.php:
$db['default']['char_set'] = 'utf8';
$db['default']['dbcollat'] = 'utf8_general_ci';
I am also using utf8_encode on data from forms before inserting it into the database, but when I extract the data thing gets displayed. The database is also configured with utf8_general_ci. In short my question is: how should I configure CodeIgniter and MySQL to be able to both insert and extract data from the database without issues ? Should I use utf8_encode before submitting the data or is that just double encoding and a part of the issue ?
PS! I don't think datatables are part of the problem since the field is already empty when data gets sent to the datatables.
PS2! I'm not sure why, but I'm only facing issues with uppercase norwegian letters. Ø fails to display, but ø work fine. Å fails to display, but å works fine.
I had a similar problem last week & I figured out that it wasn’t the DB that had problem but it was the way the Codeigniter transacts the data.
So every time before saving the data in the database, I pass the data through
htmlentities($str, ENT_QUOTES | ENT_HTML401, "UTF-8");
And before showing the data in html, I again pass it through
html_entity_decode($str, ENT_COMPAT | ENT_HTML401, 'UTF-8')
Just for record, I have this in my DB Config file
$db['default']['char_set'] = 'utf8';
$db['default']['dbcollat'] = 'utf8_general_ci';
Try to use this:
mysql_select_db('db_name');
mysql_query("SET NAMES 'utf8'");
Put mysql_query("SET NAMES 'utf8'"); after select database line
Hi has anyone had experience with using AES_DECRYPT and codeigniters active record. I've tried using the following line:
$query = $this->db->select("AES_DECRYPT(testing,'$key') as testing");
but continue to get an sql syntax error. I've tried using a manual standard sql string which works but would prefer to stick with active record if I can.
CodeIgniter is trying to escape that, and it has no idea how to. Add FALSE as the 2nd parameter to tell it not to escape it.
// We need to escape this value before the query
$key = $this->db->escape($key);
// Tell CodeIgniter not to escape this
$this->db->select("AES_DECRYPT(testing, $key) as testing", FALSE);
I'm very new to php and mysql. I'm trying to pass the value "part(2)" to my code igniter controller. "part(2)" is one of the name of the data values in my database. After passing it to the uri segment, I extracted it using the command $value = str_replace("%20", " ", $this->uri->segment(5)); . Now when i search my database using the variable $value, it's not displaying the results. I presume the problem is with having using "()". I am wondering if it has anything to do with the data type utl8 vs latin1. My database is configured to use latin1_general_ci. I have tried changing the database field type to utl8_general_ci, but it does not work. Can anyone please help me out here?.
Have you tried var_dump($value) just to see what it contains?
Also, the result from $this->db->last_query(); might be useful to see what you are actually quering your database for. I don't see a reason why you couldn't put perenthesis in your database.
Im pretty sure both utf8 and latin1 are fine.
can you post your controller code?
firstly, if you are passing the value in your uri, do you have () in your permitted uri characters in application/config/config.php?
something like this:
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-()';
But I just tried this and my values came out with html entities: part(2) instead..
you can fix this with something like this:
input_value = html_entity_decode($input_value);