Archives

Archive for the ‘C’ Category

Since the short 1 is represented as 00 00 00 01 on big endian machines and 01 00 00 00 on little endian machines, it’s a rather straight forward matter to detect the endianness of a machine, by simply looking at how it stores a short. #include <stdio.h>   int main() { unsigned short i [...]

Jun 12th, 2011 | Filed under C, Programming

I recently wrote an article about calling C code from Java using JNI. Another way to call C code from Java is to use Java Native Access, which makes things significantly easier. First off, we’ll need to write the C library. Create a ctest.c file containing a simple helloFromC function: /* ctest.c */   #include [...]

Apr 22nd, 2011 | Filed under C, Java

In this tutorial we’ll be creating a Java application calling code from a native library. We’ll have a Java application called HelloWorld which will call the function helloFromC from a shared library named “ctest“, using Java Native Interface. First off, we’ll create a file named HelloWorld.java to contain the HelloWorld class. /* HelloWorld.java */   [...]

Apr 17th, 2011 | Filed under C, Java

There are multiple ways of initializing an ICU Unicode string in C, but what I found the most convenient is the u_strFromUTF8() function.

May 14th, 2010 | Filed under C, ICU, Unicode