You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
UT_SONAR_TEST_REPORTER: wrong/missing encoding information #676
We should add charset encoding based on the current session's charset setting.
We should also check other reporters which might be affected from charset mismatch/missing information.
Hi @pesse did you check this on develop branch. A failure message was changed to no longer use a cddata but to convert message by xml for 3.1.2. Wonder if that will help.
Trouble is - I cant find any valuable info on how to detect current encoding and put it into XML.
I think there are 2 way to move from here:
Encode everything in utf-8 and then we don't need to specify encoding - that is an issue wfor characters beyond utf-8
Encode in current session encoding - but I have no idea how to get the info on that encoding in a format compatible with XML expected values for encoding
Having that function we can now convert Oracle character-set name to IANA name.
selectutl_i18n.map_charset(value) iana_charser,
value oracle_charset
from v$nls_valid_values x
where parameter ='CHARACTERSET';
We could now use the below query to get the XML/HTML encoding based on database character set.
selectutl_i18n.map_charset(value), value from v$nls_parameters where parameter ='NLS_CHARACTERSET';
The trouble is however that we don't know client-side encoding.
Then NLS_LANG fundamentals says:
Note:
SELECT USERENV ('language') FROM DUAL; gives the session's <Language>_<territory> but the DATABASE character set not the client, so the value returned is not the client's complete NLS_LANG setting!
The part of NLS_LANG is NOT shown in any system table or view.
On Windows you have two possible options, normally the NLS_LANG is set in the registry, but it can also be set in the environment, however this is not often done and generally not recommended to do so. The value in the environment takes precedence over the value in the registry and is used for ALL Oracle_Homes on the server if defined as a system environment variable.
Conclusions?
We need to take one of 2 actions:
provide NLS_LANG from client to utPLSQL to allow for generation of proper XML/HTML encoding and update reporters to include that information based on client
add the encoding on client side using ora_i18n.map_charset to convert from Oracle to IANA character-set name.
Note
Not all Oracle character-sets have a corresponding mapping
See select value from v$nls_valid_values where parameter = 'CHARACTERSET' and utl_i18n.map_charset(value) is null; for character-sets that do not have corresponding IANA name
Activity
lwasylow commentedon May 25, 2018
Hi @pesse did you check this on develop branch. A failure message was changed to no longer use a cddata but to convert message by xml for 3.1.2. Wonder if that will help.
pesse commentedon May 25, 2018
Can you point to the commit?
lwasylow commentedon May 25, 2018
It's in PR
#669
pesse commentedon May 25, 2018
Can't see how this should solve the problem to be honest.
jgebal commentedon May 25, 2018
It will not help when there are special characters in test description for example
jgebal commentedon May 25, 2018
Trouble is - I cant find any valuable info on how to detect current encoding and put it into XML.
I think there are 2 way to move from here:
utf-8and then we don't need to specify encoding - that is an issue wfor characters beyond utf-8encodingjgebal commentedon Jun 4, 2018
After some digging around here is what I've found.
Resources
Info on allowed&valid values for
encodingin XML here.That page links to iana.org with list of all Character-sets names.
Converting between Oracle and IANA names
Lookup of Oracle to IANA on google led me to ora_i18n.map_charset function.
Having that function we can now convert Oracle character-set name to IANA name.
We could now use the below query to get the XML/HTML
encodingbased on database character set.The trouble is however that we don't know client-side encoding.
Then NLS_LANG fundamentals says:
Conclusions?
We need to take one of 2 actions:
encodingand update reporters to include that information based on clientencodingon client side usingora_i18n.map_charsetto convert from Oracle to IANA character-set name.pesse commentedon Jun 7, 2018
New plan after ongoing discussion in utPLSQL/utPLSQL-cli#78:
<?xml version="1.0" encoding="$a_encoding"?><meta charset="$a_encoding">in head sectionI guess the latter two tasks will require to add new param to ut_output_reporter type - might also need additional care in java-api for compatibility.