[sword-devel] Sword C# bindings for Windows

Jon Behrens jbb at crimsonthread.com
Tue Oct 7 12:56:21 MST 2014


Hello again,

There are some breaking differences between the Windows version of 
'libsword'
and the Linux version. When executing the same C# code I get different 
results
depending on which OS I am running. Here is the code I'm running (the 
two OSs
use the same file with symbolic links, so they are identical.)

public static void testBench(string modName, string outfile) {
StreamWriter sw = new StreamWriter(outfile, false, Encoding.Unicode);
using (var manager = new Manager(Enviro.swordHome)) {
var module = manager.GetModuleByName(modName);
if (module == null) {
sw.WriteLine("******Error*******");
sw.WriteLine("Could not find {0}.", modName);
}
module.KeyText = "gen.1.3";
while (!module.PopError()) {
sw.WriteLine(module.KeyText);
sw.WriteLine(module.RenderText());
sw.WriteLine("RawEntry length = " + module.RawEntry.Length);
sw.WriteLine("EntrySize = " + module.EntrySize);
module.Prevous();
}
}
sw.Close();
}

*********Linux Version ************
Genesis 1:3
And God said, “Let there be light,” and there was light.
RawEntry length = 358
EntrySize = 362

Genesis 1:2
The earth was without form and void, and darkness was over the face of 
the deep. And the Spirit of God was hovering over the face of the 
waters. <br />
<br />
RawEntry length = 348
EntrySize = 348

Genesis 1:1
In the beginning, God created the heavens and the earth.
RawEntry length = 879
EntrySize = 879

************Windows Version*****************
Genesis 1:3
And God said, “Let there be light,” and there was light.
RawEntry length = 362
EntrySize = 7513747286636101994

Genesis 1:2
The earth was without form and void, and darkness was over the face of 
the deep. And the Spirit of God was hovering over the face of the 
waters. <br />
<br />
RawEntry length = 348
EntrySize = 7513747286636101980

Genesis 1:1
In the beginning, God created the heavens and the earth.
RawEntry length = 879
EntrySize = 7513747286636102511
**********************************************

Notice in the Linux version the quotes in Gen.1.3 around "Let there be 
light," render
properly and those in Windows do not.

The underlying function in flatapi.cpp is:
const char SWDLLEXPORT * org_crosswire_sword_SWModule_renderText 
(SWHANDLE hSWModule)

Notice that the two entry lengths give different numbers in Linux than 
Windows. (In neither
case do the numbers appear to mean anything with Windows having the 
advantage of not even
looking reasonable.)

At first blush, it looks as if there is a compiler option not properly 
set in Windows so that unicode
module text is being processed as ASCII which is then being passed to C#.

Thanks for any help - and blessings,
Jon




More information about the sword-devel mailing list