You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

native2ascii.html 9.1 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. <!--
  2. Licensed to the Apache Software Foundation (ASF) under one or more
  3. contributor license agreements. See the NOTICE file distributed with
  4. this work for additional information regarding copyright ownership.
  5. The ASF licenses this file to You under the Apache License, Version 2.0
  6. (the "License"); you may not use this file except in compliance with
  7. the License. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. -->
  15. <html>
  16. <head><link rel="stylesheet" type="text/css" href="../stylesheets/style.css">
  17. <title>Native2Ascii Task</title></head>
  18. <body>
  19. <h2>Native2Ascii</h2>
  20. <h3>Description:</h3>
  21. <p>
  22. Converts files from native encodings to ASCII with escaped Unicode.
  23. A common usage is to convert source files maintained in a native
  24. operating system encoding, to ASCII prior to compilation.
  25. </p>
  26. <p>
  27. Files in the directory <em>src</em>
  28. are converted from a native encoding to ASCII.
  29. By default, all files in the directory are converted.
  30. However, conversion may be limited to selected files using
  31. <em>includes</em> and <em>excludes</em> attributes.
  32. For more information on file matching patterns,
  33. see the section on
  34. <a href="../dirtasks.html#directorybasedtasks">directory based tasks</a>.
  35. If no <em>encoding</em> is specified,
  36. the default encoding for the JVM is used.
  37. If <em>ext</em> is specified, then output files are renamed
  38. to use it as a new extension.
  39. More sophisticated file name translations can be achieved using a nested
  40. <em><code>&lt;mapper&gt;</code></em> element. By default an
  41. <a href="../Types/mapper.html#identity-mapper">identity mapper</a> will be used.
  42. If <em>dest</em> and <em>src</em> point to the same directory,
  43. the <em>ext</em> attribute or a nested <em><code>&lt;mapper&gt;</code></em>
  44. is required.
  45. </p>
  46. <p>
  47. This task forms an implicit <a href="../Types/fileset.html">File Set</a>,
  48. and supports most attributes of <code>&lt;fileset&gt;</code>
  49. (<code>dir</code> becomes <code>src</code>) as well as
  50. nested <code>&lt;include&gt;</code>, <code>&lt;exclude&gt;</code>,
  51. and <code>&lt;patternset&gt;</code> elements.
  52. </p>
  53. <p>It is possible to use different converters. This can be selected
  54. with the <code>implementation</code> attribute or a nested element.
  55. <a name="implementationvalues">Here are the choices of the attribute</a>:</p>
  56. <ul>
  57. <li>default - the default converter for the platform - kaffee
  58. when run on Kaffee, builtin otherwise.</li>
  59. <li>sun (used to be the standard converter of the JDK < 9)</li>
  60. <li>kaffe (the standard converter
  61. of <a href="http://www.kaffe.org" target="_top">Kaffe</a>)</li>
  62. <li>builtin - Ant's internal implementation. <em>since ant
  63. 1.9.8</em></li>
  64. </ul>
  65. <table border="1" cellpadding="2" cellspacing="0">
  66. <tr>
  67. <td><b>Attribute</b></td>
  68. <td><b>Description</b></td>
  69. <td><b>Required</b></td>
  70. </tr>
  71. <tr>
  72. <td>reverse</td>
  73. <td>Reverse the sense of the conversion,
  74. i.e. convert from ASCII to native <b>only supported by the
  75. sun and builtin converters</b></td>
  76. <td align="center">No</td>
  77. </tr>
  78. <tr>
  79. <td>encoding</td>
  80. <td>The native encoding the files are in
  81. (default is the default encoding for the JVM)</td>
  82. <td align="center">No</td>
  83. </tr>
  84. <tr>
  85. <td>src</td>
  86. <td>The directory to find files in (default is <em>basedir</em>)</td>
  87. <td align="center">No</td>
  88. </tr>
  89. <tr>
  90. <td>dest</td>
  91. <td>The directory to output file to</td>
  92. <td align="center">Yes</td>
  93. </tr>
  94. <tr>
  95. <td>ext</td>
  96. <td>File extension to use in renaming output files</td>
  97. <td align="center">No</td>
  98. </tr>
  99. <tr>
  100. <td>defaultexcludes</td>
  101. <td>indicates whether default excludes should be used or not
  102. (&quot;yes&quot;/&quot;no&quot;).
  103. Default excludes are used when omitted.
  104. </td>
  105. <td align="center">No</td>
  106. </tr>
  107. <tr>
  108. <td>includes</td>
  109. <td>comma- or space-separated list of patterns of files that must be
  110. included. All files are included when omitted.</td>
  111. <td align="center">No</td>
  112. </tr>
  113. <tr>
  114. <td>includesfile</td>
  115. <td>the name of a file. Each line of this file is
  116. taken to be an include pattern</td>
  117. <td align="center">No</td>
  118. </tr>
  119. <tr>
  120. <td>excludes</td>
  121. <td>comma- or space-separated list of patterns of files that must be excluded.
  122. No files (except default excludes) are excluded when omitted.</td>
  123. <td align="center">No</td>
  124. </tr>
  125. <tr>
  126. <td>excludesfile</td>
  127. <td>the name of a file. Each line of this file is
  128. taken to be an exclude pattern</td>
  129. <td align="center">No</td>
  130. </tr>
  131. <tr>
  132. <td valign="top">implementation</td>
  133. <td valign="top">The converter implementation to use.
  134. If this attribute is not set, the default converter for the
  135. current VM will be used. (See the above <a
  136. href="#implementationvalues">list</a> of valid converters.)</td>
  137. <td align="center" valign="top">No</td>
  138. </tr>
  139. </table>
  140. <h3>Parameters specified as nested elements</h3>
  141. <h4>arg</h4>
  142. <p>You can specify additional command line arguments for the converter
  143. with nested <code>&lt;arg&gt;</code> elements. These elements are
  144. specified like <a href="../using.html#arg">Command-line Arguments</a>
  145. but have an additional attribute that can be used to enable arguments
  146. only if a given converter implementation will be used.</p>
  147. <table border="1" cellpadding="2" cellspacing="0">
  148. <tr>
  149. <td width="12%" valign="top"><b>Attribute</b></td>
  150. <td width="78%" valign="top"><b>Description</b></td>
  151. <td width="10%" valign="top"><b>Required</b></td>
  152. </tr>
  153. <tr>
  154. <td valign="top">value</td>
  155. <td align="center" rowspan="4">See
  156. <a href="../using.html#arg">Command-line Arguments</a>.</td>
  157. <td align="center" rowspan="4">Exactly one of these.</td>
  158. </tr>
  159. <tr>
  160. <td valign="top">line</td>
  161. </tr>
  162. <tr>
  163. <td valign="top">file</td>
  164. </tr>
  165. <tr>
  166. <td valign="top">path</td>
  167. </tr>
  168. <tr>
  169. <td valign="top">implementation</td>
  170. <td>Only pass the specified argument if the chosen converter
  171. implementation matches the value of this attribute. Legal values
  172. are the same as those in the above <a
  173. href="#implementationvalues">list</a> of valid compilers.)</td>
  174. <td align="center">No</td>
  175. </tr>
  176. </table>
  177. <h4>implementationclasspath <em>since Apache Ant 1.8.0</em></h4>
  178. <p>A <a href="../using.html#path">PATH like structure</a> holding the
  179. classpath to use when loading the converter implementation if a
  180. custom class has been specified. Doesn't have any effect when
  181. using one of the built-in converters.</p>
  182. <h4>Any nested element of a type that implements Native2AsciiAdapter
  183. <em>since Ant 1.8.0</em></h4>
  184. <p>If a defined type implements the <code>Native2AsciiAdapter</code>
  185. interface a nested element of that type can be used as an
  186. alternative to the <code>implementation</code> attribute.</p>
  187. <h3>Examples</h3>
  188. <pre>
  189. &lt;native2ascii encoding=&quot;EUCJIS&quot; src=&quot;srcdir&quot; dest=&quot;srcdir&quot;
  190. includes=&quot;**/*.eucjis&quot; ext=&quot;.java&quot;/&gt;
  191. </pre>
  192. <p>
  193. Converts all files in the directory <em>srcdir</em>
  194. ending in <code>.eucjis</code> from the EUCJIS encoding to ASCII
  195. and renames them to end in <code>.java</code>.
  196. </p>
  197. <pre>
  198. &lt;native2ascii encoding=&quot;EUCJIS&quot; src=&quot;native/japanese&quot; dest=&quot;src&quot;
  199. includes=&quot;**/*.java&quot;/&gt;
  200. </pre>
  201. <p>
  202. Converts all the files ending in <code>.java</code>
  203. in the directory <em>native/japanese</em> to ASCII,
  204. placing the results in the directory <em>src</em>.
  205. The names of the files remain the same.
  206. </p>
  207. <p>If you want to use a custom
  208. Native2AsciiAdapter <code>org.example.MyAdapter</code> you can either
  209. use the implementation attribute:</p>
  210. <pre>
  211. &lt;native2ascii encoding="EUCJIS" src="srcdir" dest="srcdir"
  212. includes="**/*.eucjis" ext=".java"
  213. implementation="org.example.MyAdapter"/&gt;
  214. </pre>
  215. <p>or a define a type and nest this into the task like in:</p>
  216. <pre>
  217. &lt;componentdef classname="org.example.MyAdapter"
  218. name="myadapter"/&gt;
  219. &lt;native2ascii encoding="EUCJIS" src="srcdir" dest="srcdir"
  220. includes="**/*.eucjis" ext=".java"&gt;
  221. &lt;myadapter/&gt;
  222. &lt;/native2ascii&gt;
  223. </pre>
  224. <p>in which case your native2ascii adapter can support attributes and
  225. nested elements of its own.</p>
  226. </body>
  227. </html>