• What do you need help with? Version 5
    5,752 replies, posted
[QUOTE=Eudoxia;37857297]I know about the printable glyph != code point thing, but since I am just looking to output the string as an array of numbers, I should just output the array of codepoints, no?[/QUOTE] I really don't know what you mean. What's the purpose of outputting the string as an array of numbers? If it's to debug things, you could output the code points I guess. But it's not really meaningful.
[QUOTE=Jookia;37857371]I really don't know what you mean. What's the purpose of outputting the string as an array of numbers? If it's to debug things, you could output the code points I guess. But it's not really meaningful.[/QUOTE] I need some way to compile strings, and since I don't think LLVM IR will handle Unicode strings (Though there's no harm in trying I guess), I thought it would be better to print a null-terminated array of integers with the bit-width of the string's encoding, where each element has the value of the same element/code point in the original input string/array. 'Meaningful', well, that depends. If a plain array of code points isn't printed the same way as a 'proper' Unicode string, then I suppose not.
Can't you just compile the strings though? Like, the bytes of it? A UTF-8 encoded string is a null terminated array of integers.
[QUOTE=Jookia;37857712]Can't you just compile the strings though? Like, the bytes of it? A UTF-8 encoded string is a null terminated array of integers.[/QUOTE] That's sort of what I'm trying to do, but do you mean that, for example, when compiling a UTF-32 string, I should split each integer into its compounding bytes and print everyone in order? All into an i8/char array?
[QUOTE=Eudoxia;37857820]That's sort of what I'm trying to do, but do you mean that, for example, when compiling a UTF-32 string, I should split each integer into its compounding bytes and print everyone in order? All into an i8/char array?[/QUOTE] Don't use UTF-32. Use UTF-8 everywhere. Only when interacting with external stuff convert it to what it needs to be.
[QUOTE=Jookia;37857839]Don't use UTF-32. Use UTF-8 everywhere. Only when interacting with external stuff convert it to what it needs to be.[/QUOTE] What if the user gives me a UTF-32 string? Do I have to do that thing I said to convert it to UTF-8, or it is some other process?
[QUOTE=Eudoxia;37857894]What if the user gives me a UTF-32 string? Do I have to do that thing I said to convert it to UTF-8, or it is some other process?[/QUOTE] Don't let a user give you a UTF-32 string? If you absolutely must, use code to convert it to UTF-8.
[QUOTE=Eudoxia;37857894]What if the user gives me a UTF-32 string? Do I have to do that thing I said to convert it to UTF-8, or it is some other process?[/QUOTE] That would be a smart thing to do, yes. In addition, I have literally never heard of anyone using UTF-32 as their locale encoding.
Okay, so no UTF-32 whatsoever, I think I can live with that. Just to be clear: Compiling a UTF-8 string is just emitting an array of 8-bit-wide integers and filling it with the code points, right?
[QUOTE=Eudoxia;37857965]Okay, so no UTF-32 whatsoever, I think I can live with that. Just to be clear: Compiling a UTF-8 string is just emitting an array of 8-bit-wide integers and filling it with the code points, right?[/QUOTE] No, it's a lot more tricky than that. You may want to use a library to do it, but [url=https://en.wikipedia.org/wiki/UTF-8#Description]the actual way of storage is ingenious[/url]. It maintains backwards compatibility with ASCII as one of its features, so the NULL byte will work as a terminator.
[QUOTE=Jookia;37857998]No, it's a lot more tricky than that. You may want to use a library to do it, but [url=https://en.wikipedia.org/wiki/UTF-8#Description]the actual way of storage is ingenious[/url]. It maintains backwards compatibility with ASCII as one of its features, so the NULL byte will work as a terminator.[/QUOTE] Thanks, I'll look into it or get a simple encoder library.
Converting UTF-8 to other encodings is relatively simple, or so I understood (you mostly need to do ands and bit-shifting, don't you)
[QUOTE=esalaka;37858237]Converting UTF-8 to other encodings is relatively simple, or so I understood (you mostly need to do ands and bit-shifting, don't you)[/QUOTE] Doesn't the difficulty depend very much on the other encoding?
What do you guys think of the code [URL="http://stackoverflow.com/questions/2113270/how-to-read-unicode-utf-8-binary-file-line-by-line"]here[/URL]? Would it work to get UTF-8 input and export an array of integers?
[B]Quick Question : [/B]What would you guys recommend for compiling C files? I'm using Sublime Text to write code, but am yet to find a quick, easy to use compiler.
[QUOTE=Occlusion;37858956][B]Quick Question : [/B]What would you guys recommend for compiling C files? I'm using Sublime Text to write code, but am yet to find a quick, easy to use compiler.[/QUOTE] I like Clang on Linux, and on Windows I use MinGW (gcc) because I am a horrible person.
[QUOTE=Eudoxia;37858980]I like Clang on Linux, and on Windows I use MinGW (gcc) because I am a horrible person.[/QUOTE] You should be using Clang on Windows too!
[QUOTE=T3hGamerDK;37859088]You should be using Clang on Windows too![/QUOTE] But I don't know how to ;_; do I have to build it from source? Because that is a serious no, I am a [URL="http://boomstickcomics.com/wp-content/uploads/2011/09/comic_book_guy_by_jimboy_sk8s-d2y9ind.jpg"]busy man[/URL].
[QUOTE=ArgvCompany;37858263]Doesn't the difficulty depend very much on the other encoding?[/QUOTE] Other... UTF-encodings, I meant.
[QUOTE=Eudoxia;37859135]But I don't know how to ;_; do I have to build it from source? Because that is a serious no, I am a [URL="http://boomstickcomics.com/wp-content/uploads/2011/09/comic_book_guy_by_jimboy_sk8s-d2y9ind.jpg"]busy man[/URL].[/QUOTE] Building it with Clang doesn't take long though.
[QUOTE=Occlusion;37858956][B]Quick Question : [/B]What would you guys recommend for compiling C files? I'm using Sublime Text to write code, but am yet to find a quick, easy to use compiler.[/QUOTE] Avoid Microsoft's compiler if you can. It's outdated by decades and doesn't play nice with others.
Looks like there's Unicode support somewhere in the LLVM API: [CPP]#include <stdio.h> int main(){ printf("&#44032;&#48000;&#51000;&#55203;"); printf("&#2822; &#2832; &#2848;&#2903; &#2921;\n"); return 0; }[/CPP] [CODE]@.str = private constant [13 x i8] c"\EA\B0\80\EB\AE\80\EC\9C\B8\ED\9E\A3\00" @.str1 = private constant [20 x i8] c"\E0\AC\86 \E0\AC\90 \E0\AC\A0\E0\AD\97 \E0\AD\A9\0A\00"[/CODE] Send in a rescue team if I don't return in eleven days.
If you save your sources as UTF-8 and are in an UTF-8 locale, literals work just fine.
[QUOTE=esalaka;37859294]If you save your sources as UTF-8 and are in an UTF-8 locale, literals work just fine.[/QUOTE] The only 'problem' now is converting the Unicode string into a stream of hexadecimals.
That, to me, just looks like a stream of hexadecimals that match the separate bytes of the codepoints? I could be wrong.
[QUOTE=esalaka;37859600]That, to me, just looks like a stream of hexadecimals that match the separate bytes of the codepoints? I could be wrong.[/QUOTE] That's exactly what it is, and it sort of seems to work. I guess it's not full-fledged Unicode support, but as long as LLVM can parse it and print it out, I'm fine with it. More complex Unicode string manipulation will come later as part of the standard library or something. [CPP]#include <cstdio> #include <string> #include <iostream> int main() { using namespace std; string penis = "&#44032;&#48000;&#51000;&#55203;"; string result; for(unsigned long i = 0; i < penis.length(); i++) { char appendee[10]; sprintf(appendee,"%X",penis[i]); result += (string)"\\" + appendee[6] + appendee[7]; } result += "\00"; cout << "Input: " << penis << endl; cout << "Output: " << result << endl; return 0; }[/CPP] [CODE] Input: &#44032;&#48000;&#51000;&#55203; Output: \EA\B0\80\EB\AE\80\EC\9C\B8\ED\9E\A3 [/CODE] Then, I emit the parsed unicode string into an array like I would emit any other array, and LLVM takes over from there. I have no idea how anything works anymore [IMG]http://www.dustloop.com/forums/images/smilies/custom/toot.gif[/IMG]
Crack open LLVM's source code. You should always understand how an API works. Not implementation, I mean logically.
I need help with drawing an image in 3D, thanks to Java not having image warping in it's API. So I have an image. I divide the image into a series of pixels by each vertical line of pixels. For each line of pixels on the image, I want to draw the pixels a little bit bigger. Now to do that, I need the scale (or size of the line of pixels) at which to multiply the size of the line of pixels, each line because it's increasing in height (z value), in this case, by the ___________ (difference in pixels for each z value that the line of pixels changes or something?). To do that, I need to find the scale at which to multiply the pixels. What is that? It gets worse. Imagine I'm drawing a two dimensional wall in 3D (like this -> | ) Now, after I'm done with finding the scale at which to multiply the size of the line of pixels, I must draw each line of pixels, skipping the pixels between each line of pixels on the destination image, meaning that I need to fill in the void between the height at the first line of pixels, and the last line. I'm only drawing sideways at the moment, horizontally will happen later. And I'm stumped. My brain is dead. I worked out some of the math, but I can't even do the rest. I've worked at this for the past four hours and I can't find a solution, getting only various image artifacts. [CODE]public void drawTestTexture(Graphics2D gfx, clsTexture texture,int x, int y,int z) { //Tsub1 is the difference between the two actual x values for a projected x,y,z value (aka vector from the bottom center // of the screen. double tsub1 = (Xin3D(x, 0, program.interfacemanager.view_x,program.interfacemanager.view_y) - Xin3D(x, z, program.interfacemanager.view_x,program.interfacemanager.view_y)); //Tsub2 is the difference between the two actual y values for a projected x,y,z value (aka vector from the bottom center //of the screen). double tsub2 = (Yin3D(y, 0, program.interfacemanager.view_x,program.interfacemanager.view_y) - Yin3D(y, z, program.interfacemanager.view_x,program.interfacemanager.view_y)); double fofx = tsub1 /texture.width;//As I need to draw the whole image, fofx and fofy are the values I increase I by each // pass to draw across the image. double fofy = tsub2/texture.height; int n = 0; //the counter by which I draw across the source image. //This next one means I go across the image by each increment of the value fofx, to get to the end of the image each time, //depending on the difference of each pixel line. for(double i = 0; (Math.abs(i) < Math.abs(tsub1));i+=fofx) //for(n=0;n<texture.width;n++) { //and here's the problem, I don't know what to multiply what to get the result I want. gfx.drawImage(texture.data, (int)Xin3D(x+n,0,program.interfacemanager.view_x,program.interfacemanager.view_y), (int)Yin3D(y,0,program.interfacemanager.view_x,program.interfacemanager.view_y), (int)Xin3D(x+n+1,0,program.interfacemanager.view_x,program.interfacemanager.view_y), (int)Yin3D(y+texture.height*,0,program.interfacemanager.view_x,program.interfacemanager.view_y), n, 0, n+1, texture.height, null); //gfx.drawImage(texture.data, /// (int)Xin3D(x,0,program.interfacemanager.view_x,program.interfacemanager.view_y), // (int)Yin3D(y,0,program.interfacemanager.view_x,program.interfacemanager.view_y), // (int)Xin3D(x,i,program.interfacemanager.view_x,program.interfacemanager.view_y), // (int)Yin3D(y+texture.height,i,program.interfacemanager.view_x,program.interfacemanager.view_y), // n, 0, n+1, texture.height,null); n++; } } //Really long equation that reliably finds the X value for a given height of Z public double Xin3D(double x1,double zto, double viewX, double viewY) { return ((x1 - viewX) + (zto * (x1 - viewX - this.program.graphicsloop.resolution_x/2)) / this.program.graphicsloop.resolution_x/2); } //Really long equation that reliably finds the Y value for a given height of Z public double Yin3D(double y1,double zto, double viewX, double viewY) { return ((y1 - viewY) + (zto * (y1 - viewY - this.program.graphicsloop.resolution_y*0.625)) / this.program.graphicsloop.resolution_y*0.625); }[/CODE] Dear god if someone figures this out you get a medal. I added some comments for understanding.
If there is anyone here with good Android SDK and Eclipse knowledge and wouldn't mind taking off some minutes to help me with some small time application development every now and then, pm me.
Nevermind got it working: I had to update tsub2 to this every increment of i: [CODE]double tsub2 = -(Yin3D(y, 0, program.interfacemanager.view_x,program.interfacemanager.view_y) - Yin3D(y, i, program.interfacemanager.view_x,program.interfacemanager.view_y)); [/CODE] And this was the function that got it to work. [CODE]gfx.drawImage(texture.data, (int)Xin3D(x+i,0,program.interfacemanager.view_x,program.interfacemanager.view_y), (int)Yin3D(y-Math.abs(tsub2)/2,Math.abs(i),program.interfacemanager.view_x,program.interfacemanager.view_y), (int)Xin3D(x+i+fofx,0,program.interfacemanager.view_x,program.interfacemanager.view_y), (int)Yin3D(y+texture.height+Math.abs(tsub2)/2,Math.abs(i),program.interfacemanager.view_x,program.interfacemanager.view_y), n, 0, n+1, texture.height, null);[/CODE]
Sorry, you need to Log In to post a reply to this thread.