C ++ Character buffer adding non-existent characters

0

Well, I have an application for android that uses OpenGL ES 3.1, I did the whole procedure to compile the shaders, I decided to put them in a separate folder in assets, to retrieve the content I'm using

asked by anonymous 04.05.2018 / 14:28

1 answer

0

I am very expert in Java and OpenGl.

But I've done a lot with CUDA (nvidia) programs with codes in C, C ++ and mixed Delphi. And a problem that tends to occur a lot is type compatibility.

For example, in a certain language a Int can be 2 bytes and be of type signed , while in another it can occupy 4 bytes and can be signed or unsigned . Because the machine does not actually know data types, it only receives a sequence of bits and interprets it as ordered. And that's where the problem comes from: a data was stored in an interpretation in a code of one programming language, and was obtained and manipulated with another by the other code of the other language.

As I saw the prints complaining about unknown characters, I came to this conclusion:

Java stores characters in 2 bytes unsigned spaces, ranging from 0 to 65,535, as reported here ,
already C / C ++ stores them with 1 byte signed signatures, ranging from -128 to +127.

Conventional characters belong to the ASCII table, which makes up a total of 128 characters.

The problem must have been that in Java a 238 code character (for example) was put in a C / C ++ char, and therefore did not recognize the character (since it does not belong to the ASCII table).

Try to check the types and print the contents of the string through both languages being used, so you know what's going on inside, and then correct by doing an appropriate type conversion.

    
05.05.2018 / 06:26