# Setting a charset for non-UTF Oracle DB request/response

**URL:** <https://community.dreamfactory.com/t/setting-a-charset-for-non-utf-oracle-db-request-response/1522>\
**Category:** REST API\
**Created:** [September 24, 2015, 8:55pm UTC](https://community.dreamfactory.com/t/setting-a-charset-for-non-utf-oracle-db-request-response/1522 "2015-09-24T20:55:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Matija\_Horvat](https://avatars.discourse-cdn.com/v4/letter/m/e47774/32.png) [@Matija\_Horvat](https://community.dreamfactory.com/u/Matija_Horvat)\
**Post date:** [September 24, 2015, 8:55pm UTC](https://community.dreamfactory.com/t/setting-a-charset-for-non-utf-oracle-db-request-response/1522/1 "2015-09-24T20:55:01Z")

</div>

When Dreamfactory is configured to use an Oracle DB connection, where the DB is configured with a non-UTF charset, problems might arise. Some of such problems on my configuration were Eastern Europe characters converted to flat ASCII characters (with ‘$charset = null;’) or a blank response / No content response (with ‘$charset = some\_wrong\_charset;’)

In my case, the DB itself was configured to use EE8MSWIN1250, so I needed to use a matching charset in Dreamfactory.

Setting a proper charset in DreamFactory 1.9.4-3 on Linux (I didn’t test it on Windows, but assume it should also work) can be done by editing \dreamfactory-1.9.4-3\apps\dreamfactory\htdocs\vendor\dreamfactory\yii\framework\db\schema\oci\COciPdoAdapter.php.

Specifically, it looks like this on my configuration:  
public function \_\_construct( $dsn, $username, $password, $options )  
{  
$persistent = false;  
$db = substr( $dsn, strpos( $dsn, ‘dbname=’ ) + 7 );  
// $charset = null; —\> factory setting  
$charset = ‘AL32UTF8’; —\> working custom setting  
…  
}

I have to point out that this example, generated via Dreamfactory GUI in Services section, didn’t work when the ‘;charset=AL32UTF8’ part was added):  
‘oci:dbname=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)([HOST=myOracleHost.com](http://HOST=myOracleHost.com))(PORT=1526))(CONNECT\_DATA=(SERVICE\_NAME=myService.intern)));_charset=AL32UTF8;_’

If Dreamfactory is configured to connect to more than one Oracle DB, which differ in used charsets / language environments, ‘if’ blocks combined with the ‘$charset=…’ expression may be used to match a specific ‘$charset’ with a specific ‘$dsn’ parameter.

_Kind folks at Dreamfactory, Jeffrey Stables and Drew Pearce, have significantly contributed to my efforts in finding this solution. Thank you guys!_

Regards,  
Matija
