AnsweredAssumed Answered

Generate a file in ANSI encoding

Question asked by Arthur Filiberto Employee on Jun 17, 2016
Latest reply on Jun 24, 2016 by Chris_Hackett

Is it possible to generate a file in ANSI enconding using Gel Script?

 

I am using the the follwing code, but it only creates the file in UTF-8:

<?xml version="1.0" encoding="Windows-1252"?>
<gel:script xmlns:core="jelly:core" xmlns:f="jelly:com.niku.union.gel.FileTagLibrary" xmlns:gel="jelly:com.niku.union.gel.GELTagLibrary"
                xmlns:sql="jelly:sql" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <!-- Abrir conexão com o DB-->
  <gel:setDataSource dbId="niku" var="nikuDS"/>
  <!--Formato da data atual-->
  <gel:formatDate format="yyyyMMddHHmmss" stringVar="runDateFileName"/>
  <gel:formatDate format="ddMMyyyy" stringVar="runDateLine"/>
  <!-- Parametros do arquivo-->
  <gel:parameter var="paramFilePath"/>
  <gel:parameter default="1" var="paramDebugLevel"/>
  <gel:parameter default="£¢" var="paramQuebraLinha"/>
  <gel:parameter default="/#$@%/" var="paramInicioLinha"/>
  <!--Parametros - Linha 1 - Campos fixos-->
  <!--INI:    8-->
  <gel:parameter default="2" var="paramMudanca"/>
  <!--INI:   23-->
  <!--Query-->
  <sql:query dataSource="${nikuDS}" escapeText="false" var="sqlResult"><![CDATA[


SELECT ISNULL(SUBSTRING(REPLACE(r.rim_risk_issue_code,'SM',''),1,14)      
       + replicate(' ', 14 - len(SUBSTRING(REPLACE(r.rim_risk_issue_code,'SM',''),1,14))),replicate(' ', 14)) mudanca_cod
       ,ISNULL(SUBSTRING(srm.unique_name,1,9)
       + replicate(' ', 9-len(SUBSTRING(srm.unique_name,1,9))),replicate(' ', 9))                          mudanca_soli
 FROM   RIM_RISKS_AND_ISSUES r
 INNER JOIN ODF_CA_PROJECT prj on r.PK_ID=prj.id
 WHERE  r.id = ${gel_objectInstanceId}
  ]]>
  </sql:query>
  <!--Escrevendo o arquivo-->
  <core:if test="${paramDebugLevel > 0}"><gel:log>Criando o arquivo de saída no caminho "${paramFilePath}\${runDateFileName}.txt"</gel:log>
  </core:if>
  <f:writeFile delimiter="," embedded="false" fileName="${paramFilePath}\${runDateFileName}.txt">
  <core:if test="${paramDebugLevel > 0}"><gel:log>mudanca_cod: ${sqlResult.rows[0].mudanca_cod}</gel:log>
  <gel:log>mudanca_soli: ${sqlResult.rows[0].mudanca_soli}</gel:log>
  </core:if>
  <!-- Escrever linhas-->
  <f:line>
  <f:column value="1${paramInicioLinha}${paramMudanca}${sqlResult.rows[0].mudanca_cod}"/>
  </f:line>
  </f:writeFile>
</gel:script>

Outcomes