64 lines
4.7 KiB
HTML
64 lines
4.7 KiB
HTML
|
<?xml version="1.0" encoding="UTF-8"?>
|
||
|
<!DOCTYPE html
|
||
|
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||
|
<html lang="en-us" xml:lang="en-us">
|
||
|
<head>
|
||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||
|
<meta name="security" content="public" />
|
||
|
<meta name="Robots" content="index,follow" />
|
||
|
<meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.icra.org/ratingsv02.html" l gen true r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true r (n 0 s 0 v 0 l 0) "http://www.classify.org/safesurf/" l gen true r (SS~~000 1))' />
|
||
|
<meta name="DC.Type" content="concept" />
|
||
|
<meta name="DC.Title" content="Strings in native methods" />
|
||
|
<meta name="abstract" content="Many Java Native Interface (JNI) functions accept C language-style strings as parameters. For example, the FindClass() JNI function accepts a string parameter that specifies the fully-qualified name of a classfile. If the classfile is found, it is loaded by FindClass, and a reference to it is returned to the caller of FindClass." />
|
||
|
<meta name="description" content="Many Java Native Interface (JNI) functions accept C language-style strings as parameters. For example, the FindClass() JNI function accepts a string parameter that specifies the fully-qualified name of a classfile. If the classfile is found, it is loaded by FindClass, and a reference to it is returned to the caller of FindClass." />
|
||
|
<meta name="DC.Relation" scheme="URI" content="jni.htm" />
|
||
|
<meta name="DC.Relation" scheme="URI" content="literal.htm" />
|
||
|
<meta name="DC.Relation" scheme="URI" content="dynamic.htm" />
|
||
|
<meta name="copyright" content="(C) Copyright IBM Corporation 2006" />
|
||
|
<meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 2006" />
|
||
|
<meta name="DC.Format" content="XHTML" />
|
||
|
<meta name="DC.Identifier" content="strings" />
|
||
|
<meta name="DC.Language" content="en-us" />
|
||
|
<!-- All rights reserved. Licensed Materials Property of IBM -->
|
||
|
<!-- US Government Users Restricted Rights -->
|
||
|
<!-- Use, duplication or disclosure restricted by -->
|
||
|
<!-- GSA ADP Schedule Contract with IBM Corp. -->
|
||
|
<link rel="stylesheet" type="text/css" href="./ibmdita.css" />
|
||
|
<link rel="stylesheet" type="text/css" href="./ic.css" />
|
||
|
<title>Strings in native methods</title>
|
||
|
</head>
|
||
|
<body id="strings"><a name="strings"><!-- --></a>
|
||
|
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
||
|
<h1 class="topictitle1">Strings in native methods</h1>
|
||
|
<div><p>Many Java™ Native Interface (JNI) functions accept C language-style
|
||
|
strings as parameters. For example, the FindClass() JNI function accepts a
|
||
|
string parameter that specifies the fully-qualified name of a classfile. If
|
||
|
the classfile is found, it is loaded by FindClass, and a reference to it is
|
||
|
returned to the caller of FindClass.</p>
|
||
|
<p>All JNI functions expect their string parameters to be encoded in UTF-8.
|
||
|
For details on UTF-8, you can refer to the JNI Specification, but in most
|
||
|
cases it is enough to observe that 7-bit American Standard Code for Information
|
||
|
Interchange (ASCII) characters are equivalent to their UTF-8 representation.
|
||
|
7-bit ASCII characters are actually 8-bit characters but their first bit is
|
||
|
always 0. So, most ASCII C strings are actually already in UTF-8.</p>
|
||
|
<p>The C compiler on the iSeries™ server operates in extended binary-coded
|
||
|
decimal interchange code (EBCDIC) by default, so you can provide strings to
|
||
|
the JNI functions in UTF-8. There are two ways to do this. You can use literal
|
||
|
strings, or you can use dynamic strings. <a href="literal.htm">Literal
|
||
|
strings</a> are strings whose value is known when the source code is compiled. <a href="dynamic.htm">Dynamic strings</a> are strings whose value is not
|
||
|
known at compile time, but is actually computed at run time.</p>
|
||
|
</div>
|
||
|
<div>
|
||
|
<ul class="ullinks">
|
||
|
<li class="ulchildlink"><strong><a href="literal.htm">Literal strings in native methods</a></strong><br />
|
||
|
It is easier to encode literal strings in UTF-8 if the string is composed of characters with a 7-bit American Standard Code for Information Interchange (ASCII) representation.</li>
|
||
|
<li class="ulchildlink"><strong><a href="dynamic.htm">Convert dynamic strings to and from EBCDIC, Unicode, and UTF-8</a></strong><br />
|
||
|
To manipulate string variables that are computed at run time, it may be necessary to convert strings to and from extended binary-coded decimal interchange (EBCDIC), Unicode, and UTF-8.</li>
|
||
|
</ul>
|
||
|
|
||
|
<div class="familylinks">
|
||
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="jni.htm" title="You should only use native methods in cases where pure Java cannot meet your programming needs.">Use the Java Native Interface for native methods</a></div>
|
||
|
</div>
|
||
|
</div>
|
||
|
</body>
|
||
|
</html>
|