Programming :: Garbage After Exactly Eight Properly Printed Characters?
Jul 21, 2010
The code below prints garbage if I use puts() but it is fine if I use printf() instead (see sample of output at the bottom of this post). The odd thing is that the mess always starts after exactly eight properly printed characters. That sort of regularity can't be a coincidence, can it? It almost looks like an encoding issue (I'm using UTF-8) but if it really is, then I don't understand why the printf() is unaffected.
Code:
#include <stdio.h>
#include <string.h>
const char *nChars (const char *, int);
int main (int argc, char * argv[]){
char * name ="Count Dracula++";
int len = strlen(name);
if (argv[1] == 0) argv[1]="printf";
printf("--->%d characters", len); .....
I have installed scim and anthy. Most Japanese characters display, but some websites and files show garbage characters. Is there any way to resolve this?
I have my OpenSuse 11.1 box set up with utf-8, however, every time I try to open a file with utf-8 characters with vi it can't handle those characters properly.
Now we are implementing our own shell using C++. What upseting us is the history command function, we use an array to store the history commands, and print the when receiving the up and down arrow buttons. The problem is we cannot modify the history command already printed on the terminal, we even cannot move the cursur, let alone modifying the command.
I'm interested in writing a generational garbage collector in C++. This is for a Python-like programming language project. I have used Boehm's garbage collector before, but I'm worried that it will have noticeable pause times (unacceptable for interactive programs). Since I can't really find any other C++ established GCs out there, I have been thinking of simply writing my own.
However, there are two essential ingredients I need for this:
- Some kind of write barrier mechanism that will notify my collector when something is written to a part of the heap
- A way for me to know the addresses and sizes of the stack, heap and global storage (the root sets)
how to implement write barriers (and how to get the stack, heap and global storage information) on the Linux platform? As an alternative, if you know of C++ GCs other than Boehm, I would also be interested.
I actually have two reasons for posting this. One is to see if there's an actual name for characters like this:Hopefully that will show up correctly for you. If not, it's a little box with four numbers in it, one in each corner. I don't know their name or their reason for showing up, so it's hard to look for help.
My main problem, though, is that I wrote a program that prints some output to a console using ncurses as it runs. These characters show up on the console, seemingly at random, and disturb the whole thing. Sometimes I'll also get sets of characters like "[13;" I'm not printing anything bizarre on there, just strings and floating-point numbers.
I want to write a driver in c so that when i released the key some message will printed in output screen. The driver should be for arm.I have a driver which read the key when it is pressed.But i want the both (means key press and release).
Debian won't display Japanese characters properly, it shows them as symbols. Is there a language pack or a particular browser plugin I need to install? It's sort of a noobish question, but I looked for something related to this issue in my Package Manager, and didn't find anything that seemed suitable/related.
I access a linux server shell via putty, but many of the keys I use do not translate across, up, down, left and right all are seen as ^[[A, ^[[B, ^[[D and ^[[C; But so is C-up, C-down, C-left and C-right. And enter is seen as C-j (which move down to the next line), and backspace is seen as C-h, which is backwards delete.
How can I stop these keys being translated into other keys (so I can, for example, configure C-h and backspace to perform two different functions) and what's doing this translation (Putty, the kernel, the shell)?
I read this guide: [URL].. but I still don't understand how to make objects created with new garbage-collected. Could someone explain how or find a link to an explanation?
I recently intalled Debian lenny and I'm having issues with some of the unicode characters. Instead of displaying the symbols properly it shows one of the following depending on font/app:
1) Square outline with four letters/numbers arranged inside 2) Just a blank square outline 3) Just a blank space
I haven't been able to test all possible characters, but from a quick check it seems that Cyrillic works properly, Japanese doesn't.A few Google searches later and I'm no wiser on how to fix the issue. Any help?
Debian "squeeze" AMD64 Some filenames, containing accented or other extended ASCII characters are not shown both in Nautilus and Terminal, nor in Virtual Console.
I also noticed than when asking octave interpreter (ran from terminal) to display character range from 97 to 140 the output was:
On the other hand, when executing the same query in qtoctave the characters are displayed properly.
I've tried to change the font that the gnome terminal uses, to no benefit.
My default locale is en_us.utf8 and I am about to install every package that contains the prefix ttf thank you for your time reading this
On Linux Mint FBReader (both the latest version and the one in the 10.04 repositories)displays Chinese characters as boxes(see screenshot) for some reason, but on Windows it works fine. Is there any way to fix it?
I have a very basic program which I wrote, to print the integer equivalents of an ASCII character. The code is below:
Code:
#include<stdio.h> int main(void) { char c;
[code]....
The code is supposed to take a character as input and print the integer equivalent of that character. But the problem is that, after printing the integer equivalent, it prints an extra '10', every time.
Code:
f 102 10
[code].....
Why does this extra '10' always come? When the code is just a simple:
Code:
#include<stdio.h> int main(void) {
[code]....
The code works just fine. There is no extra '10' displayed. I am using Ubuntu 9.10 with gcc-4.4.1.
I'm working on my ncurses application, written in C. I get user input through a loop which uses getchar(). I was able to recognize Ctrl-n by comparing the keypress to ASCII character 16, and this seems to work fine. However, if I noticed that the ASCII character for Ctrl-j (10) is the same as the Line Feed. I tested this, and if I press enter on the keyboard I get the same ASCII value as when I press Ctrl-j.
So, what do I do if I want Ctrl-j to mean something different in my program than pressing enter?The ncurses terminal mode is set to raw, with a 100 millisecond timeout, and keypad is on (I'm already using the up and down arrow-keys).
I see I'm finally posting an AWK question rather than an answer for a change I wanted to make an AWK script that would scramble all the characters in each field, but leave the first and last characters where they were.
In a file i have to grep for a particular word and cut 8 characters of that word and replace the last characters with space if it is _1.Eg: HP4350_1..i did grep|cut -c 2-9|but didn't know how to truncate the last two characters if its '_1'.i used tr '[_1] '[ ]'.but it replaced all the characters where there is a 'underscore' and 1 instead of'_1' together.
I'm trying to make a webpage that will display the bash variables I have in a file. These variables are used in a bash script that is run from on my server.The file looks like this:
I just started using eclipse. Ie, I followed all the instructions to set up C++ and run a simple hello world program.However, I seem to have hit a snag.When I build the solution I get an error. I realized where there should be a > there is a | instead. Every time I type > the | prints instead and I have no idea how to fix this.
I wrote a java program that writes strings to a file. The strings contain foreign language characters. When I run the program in Windows, the output file shows the foreign characters. However, when I attempt the same operation in Linux, the output file shows a white question mark in a black background instead of the foreign characters. The same Linux system could display the foreign characters if I copy the output file from Windows to Linux. I tried to create the output file using gedit that my program would then add additional strings to and chose Unicode-32 for encoding but still the same problem.
What could I do to get the program to display the foreign language characters from output text file?
How can I filter ASCII quotes( ' ) and double quotes ( " ) so that I can replace them with the UTF-8 equivalent?If I copy text from a Word Document(ASCII), and upload it to a web page with PHP. The Database(UTF-8) will replace these racters with incorrect character(s).I need some function that will replace these characters but I don't know how to differentiate the ASCII quotes and the UTF-8 Quotes without (somehow) converting the string to hex, then preg_replace'ing the hex code for the symbol.
I am working on an application that will convert English text into equivalent Indian language text. Since Unicode is the standard, I will be using it. In most of the western languages each code-value directly refers to the glyph index and placing the code-values side by side will give the required display. This one to one mapping is not possible in Indian languages where rendering syllables is required rather than rendering just consonants and vowels. Many of the complex characters are made up by combining several unicode values.
My question here is: How Linux renders this Unicode text correctly? More specifically, what package is used? I believe in Windows they use Uniscribe for rendering.I believe there will be an operating system library for handling the text rendering. Or do I need to write my own rendering engine? How programs like Firefox, GEdit shows unicode text? Do they also have proprietary engines for correct rendering?