Wednesday, April 03, 2013

Unicode and Chinese Characters in Java - Reference

The following are some reference points for above subject ...

Currently, am still busy to explore further ... so to keep my self some convenience for the research later :)

Added on 26 Apr

http://javarevisited.blogspot.com/2012/01/get-set-default-character-encoding.html

http://stackoverflow.com/questions/2622911/fix-string-encoding-in-java

http://www.tutorialspoint.com/java/java_string_getbytes.htm

http://exampledepot.8waytrips.com/egs/java.nio.charset/ConvertChar.html

http://examples.javacodegeeks.com/core-java/nio/charbuffer/convert-between-character-set-encodings-with-charbuffer/

---------------------------------------------------------------------------------------------------------------

http://docs.oracle.com/javase/7/docs/api/java/io/BufferedReader.html

http://docs.oracle.com/javase/7/docs/api/java/io/InputStreamReader.html

http://www.velocityreviews.com/forums/t592855-how-to-display-input-write-chinese-text-in-java.html

http://stackoverflow.com/questions/766361/how-to-save-chinese-characters-to-file-with-java

http://www.b-t.asia/chinese/prog-java.php

https://forums.oracle.com/forums/thread.jspa?messageID=9949628&#9949628

http://users.erols.com/eepeter/chinesecomputing/programming/java.html

http://stackoverflow.com/questions/8873121/reading-chinese-characters-into-a-string-from-a-byte-buffer

http://www.mkyong.com/java/java-convert-chinese-character-to-unicode-with-native2ascii/

http://www.mandarintools.com/javaconverter.html


Saturday, January 26, 2013

Sending email with gmail smtp in Python (it's simple and powerful)

Hi, I found two python code examples and I combine them and it works. Here is the sample code.

 This example send emails using gmail smtp service, so basically it is free and is possible even if you do not have an smtp server in the office :)

Enjoy! Python is powerful :)


Sample Code in Python 2.7:

import smtplib
from email.MIMEText import MIMEText

msg_text = 'my email content is here ... !!!'
msg = MIMEText(msg_text)
msg['Subject'] = 'Hello Subject'

server = smtplib.SMTP( "smtp.gmail.com", 587 )
server.starttls()
server.login('', '')
server.sendmail('', '', msg.as_string() )

print 'email sent successfully ... yahoo!!'


Save above code into a python code file, and then at Dos prompt, type Python example.py for example :)

Wednesday, September 05, 2012

Useful Hex Code for Colors

If you are developing some applications that are needing hex code, here I find a useful url listing all the necessary color codes.

This one also good

Wednesday, August 22, 2012

An Ubuntu Bash Script to Compile a C++ Program

After I have installed the C++ and WxWidgets 2.8.12 on Ubuntu 12.04 LTS, I was having a lot of problems in compiling the sample codes given in the tutorial.

Finally, I found this command:
g++ `wx-config --cxxflags` -o OutputFileName SourceCodeFileName.cpp `wx-config --libs`

But, if every time to compile your source code file, you need to remember this command may be a bit troublesome.

So, in order to quickly compile the cpp file, I have created a simple bash script file (like a DOS batch file in Windows), which allow you to just type:

$ ./ccpp.sh hw1

* Note, this is assuming your source code file is hw1.cpp and your output file is hw1. You should create an empty directory, and it should just contain hw1.cpp file. So, after you run this script file compilation, you should see two files: hw1.cpp and hw1 (hw1 is the output file which can be run directly by typing ./hw1)


And the output will be a file hw1 which is already executable (this is assuming that there is no bugs in your code).

So, to create the bash script file, create an empty text file, and then copy the following codes into it:

#!/bin/sh
#
# This script will take one argument, the file name. For example, if you have a file called hw1.cpp and this script will compile the hw1.cpp and output # a file called hw1. To execute this script, at the terminal type:
#
# ./ccpp.sh hw1
#
clear

g++ `wx-config --cxxflags` -o $1 $1.cpp `wx-config --libs`

echo ""

echo ""

After you have typed above, save it as "ccpp.sh". Then open a terminal, and type the following at the command prompt:

$ chmod +x ccpp.sh

Then it is done. Enjoy the wxWidgets tutorial :)

Converting a Physical Linux to Virtual

Hmm ... I have done a lot of work on my Linux Lubuntu 15.10 with PHP and PostgreSQL and a few other things ... it is quite time-consuming to...