Submitting special characters, like "š č ć đ ž", over the webform in grails app - mysql

I'm developing grails app , connected to MySql database ... I have created database with utf-8 character set and with that collation ... also by default character-set is set to utf-8 on mysql server ... but I defined it explicitly for my schema
In grails app I defined in Datasource.groovy
url = "jdbc:mysql://localhost:3306/blabla?useUnicode=true&characterEncoding=utf-8"
also in Config.groovy
grails.views.gsp.encoding = "UTF-8"
grails.converters.encoding = "UTF-8"
in my .gsp files I added
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
So when I try to create new User via views/user/create.gsp , and in some field I input characters š, č, đ, ć, or ž ... the value inserted in database is something like ÄÄÄ ... but I want the value to be ččč
When I insert new user through SQL statment in MySql Workbench , it is saved as I want it with field value "ččč" , when I load that user on my list.gsp, or show.gsp I can see in browser ččč ...
So the problem is somewhere in the process when saving User via webform...
Can anyone help ?
P.S. I don't know if it is relevant, but when I type these characters in textfield on a webform I switch my keyboard from EN (English) to SR (Serbian Latin) in Language bar in Windows
Grails 1.3.7
STS 2.8.1
mysql-connector-java-5.1.18
Windows 7

I managed to make it work by using <g:uploadForm > tag instead of <g:form> , and within it, regular <g:textfield> for values I wanted to save. Beside that everything else is Grails generated, like DataSource.groovy, Config.groovy, my *.gsp files, like I explained them in question ... Does anyone know difference between these 2 tags?

The issue you are having is caused by a Grails plugin, specifically "webxml" plugin version 1.4.
You need to upgrade that plugin in your project like this:
Stop your Grails application if it's running.
Go to "%USERHOME%.grails\1.3.7\projects\%YOUR_PROJECT%\plugins" folder where %YOUR_PROJECT% is your project's name, and %USERHOME% on Windows 7 is "C:\Users\YOUR_NAME".
There should be a folder named "webxml-1.4". Delete it.
Go to your Grails project folder.
Type "grails install-plugin webxml" and confirm the upgrade to 1.4.1 if asked.
Run your application - non-English letters will now be correctly interpreted even under scaffolding.

Put a <meta charset="utf-8"> tag on your page if you're using HTML5, and set the attribute accept-charset="UTF-8" on your form elements. It seems to be necessary to reliably get your forms submitted in UTF-8 with all browsers.

Run
SET NAMES UTF8
after connect.

Related

Access will not save because of system locate

I am trying to save local Access db , my system locate is US English
I am tryign to save a db with Chinese characters.
Access gives me the following errors:
“microsoft Access cannot save the form or report,
because it displays characters from a language that cannot be saved in your current system locate,
switch your system locate to the language in the form or report, and try again”
Do I really need to switch my locate for this?
Thank you!
I think you might just be able to add the language type you're trying to use to the database. In Access Options > Language
I've never used it with Chinese, so I am unsure how your results will be, but it should work out.

Laravel 4.2 application encoding from UTF8 to iso-8859-1

The database is based on MSSql and Laravel is successfully talking to it. Database is base on latin2 encoding so my Laravel app has to be iso-8859-1 istead UTF-8. Seems like entire laravel is shouting UTF8 though. I can't find anything in config files.
I have changed database encoding in connection string to be lating1 but that still doesn't' change anything.
When an entry is made form VB desktop application (my colleague is working on that) and he saves a £ symbol to the db, it goes there fine, although when I try to read that it gives me � symbol.
On the other hand if from Form::open tag I create an entry in the database the £ gets prefixed with something weird!
Also I have added <meta charset="iso-8859-1"> to the html tag of the website but when i go in firefox to see page info still tells me that the website is in UTF8. I tried changing some of the files to the western encoding (Sublime save as ->with formating) like index.php, routes.php but the website still shows as UTF8...
Any help/ advice will be much appreciated.
To solve this I have done the following:
Changed the form helper /project/vendor/laravel/framework/src/llluminate/Html/FormBuilder.php in line 106
this:
$attributes['accept-charset'] = 'UTF-8';
to:
$attributes['accept-charset'] = 'latin1';
This way all of the forms were imputing to the database right symbols.
After this as my app is not big I have created helper to convert a given string from lating1 to UTF8 like this:
public static function convertToUtf8($string){
return $converted = iconv ('latin1' , 'utf-8' , $string);
}
And it's all working fine :)

Underscore plus numeric sequence value being appended to end of element id

Does anybody know why this would be happening?
I have an aspx page that has data populated by a repeater. For some reason a numeric sequence value is being appended to all element ids that are being created by .net. Examples of element ids.
id="SearchResults_rep_ChkBoxSelectRecord_ID_100001_0"
id="SearchResults_rep_ChkBoxSelectRecord_ID_100002_1"
id="SearchResults_rep_ChkBoxSelectRecord_ID_100003_2"
id="SearchResults_rep_ChkBoxSelectRecord_ID_100004_3"
However, the element names do not have the extra value appended:
name="SearchResults_rep_ChkBoxSelectRecord_ID_100001"
name="SearchResults_rep_ChkBoxSelectRecord_ID_100002"
name="SearchResults_rep_ChkBoxSelectRecord_ID_100003"
name="SearchResults_rep_ChkBoxSelectRecord_ID_100004"
The ids are assigned dynamically in the codebehind from an integer. ...and this does not happen when running locally, but is happening on our staging server. I am aware of the ClientIDMode if I wanted to not use the .net id auto naming convention, but it would require too many code changes if I changed that property now. I am running into wall as to why this is happening. Any ideas?
More info in case it is relevant. The staging server is running Windows Server 2003 with IIS 6
I did end up discovering a solution to this issue, it had to do with upgrading code from .net 2.0 to 4.0 and the default value of the ClientIDMode, which for .net 4.0 is Predictable.
Adding <pages clientIDMode="AutoID"> to the System.Web node in the web.config resolved the issue.

Can I add some public meta data to an encrypted Access 2010 database?

My application stores its data in an Access 2010 database (accdb) file. It's password protected, which means it's encrypted w/ AES-128.
I'd like to add some meta data to the file that's publically available. This way older verisons of my application can investigate the file to see if it's even worth trying to open. Otherwise, they'll just get the dreaded "Unrecognized Database Format" error, which is usually associated with file corruptions.
In Windows, you can right-click on a file, click "Properties" and see attributes under the Details tab. I'd love it if I add attributes like the version of my application that last touched the file, and maybe other details. I'd like to avoid having a different file extension for each version of my app!
Is it possible to add some public meta data to an encrypted Access 2010 database?
You can add custom database properties : http://support.microsoft.com/default.aspx?scid=kb;en-us;q178745
You can change the file extension of an encrypted Access database and change the properties for that extension. The extension .enc is fairly descriptive and does not seem to be widely used.
The file will open normally when clicked and ask for the password. The icon will be recognizably Access and the description, "Encrypted MS Access" in this case, will appear under Type in a directory listing.
With NTFS, you can add an alternate data stream (ADS):
notepad.exe z:\docs\testde.enc:Extra.txt
Reading the stream:
more < testde.enc:extra.txt
More information: http://www.think-techie.com/2010/04/alternate-data-streams.html
http://www.irongeek.com/i.php?page=security/altds
This is a tough nut to crack! An application must read information about the ACCDB, but that information can't be stored in the ACCDB because you want the read without opening the ACCDB. And you can't use the suggested file system methods because this must work under Wine on Mac (I assume from another of your questions).
The only solution I can see is to create a companion file (with same base name but different extension) to hold the metadata. So if your application wants to know about SomeDb.accdb, it would look for a file named SomeDb.metadata and read that instead.
I suggested a kludge for your earlier question ... unfortunately this is another. :-) However, it's a simple kludge and it should work ... even on Mac.

Store web address in MySQL and display as link in HTML

I am a PHP newbie, but I'm making progress. I have made a small mysql database and PHP form that I am using to populate a web page that shows the upcoming gigs for a musician. It shows the date, venue, etc. and works fine.
What I'm trying to add is this: I want to be able to store the web address of the venue in the database and then use that address as the href for and anchor tag that says VENUE INFO. I've called the column maplink and set it up like all my other variables. When I insert the web address in my form it gets recorded to my database as text "maplink" (no quotes) instead of the web address that I entered.
Also the HTML I'm trying to use is
<p>VENUE INFO</p>
which I'm sure is terribly wrong.
I'm using PHP 5.3.8 and MySQL 5.5.16. Any help on how to go about this?
During insert into the database, you may have forgotten to append $ symbol to maplink to make it a variable.