Skip to main content

· 2 min read

Android Scripting Environment (ASE) is the scripting language (BeanShell, Python, Lua, Ruby) environment for Android Operating System.

The following instructions are according to the discussion from ASE group.

Prerequisites **To compile ASE, you need a Linux machine, then here goes:

1. Get Android source (read http://source.android.com/download to fetch the source) and name the folder as 'mydroid'(or else you prefer). In the following instructions I assume all the folders are in user's home folder(~) .

2. Get Android SDK (download from http://developer.android.com/) and extract it as "android_sdk"(or else you prefer).

3. Get Android Scripting Environment source (hg clone from http://code.google.com/p/android-scripting/source/) as "ase"(or else you prefer).

4. Enter ase/tools folder and execute "fix_android_sdk.py" to patch the "android_sdk".

$ cd ase/tools $ python fix_android_sdk.py ~/mydroid ~/android_sdk Copying source from .....mydroid to .....android_sdk/platforms/android-[verison]/sources Adding android.os.Exec to android.jar Compiling android.os.Exec to.... Done!

In addition to modifying the SDK by adding android.os.Exec, the script will also copy the source files into the SDK so that they can be browsed in Eclipse.

Import Project into Eclipse

After executing the script, follow the instructions for developing in Eclipse in the Android developer guide to setup a workable Android development environment.

Change the project build path and specify the BeanShell path to (project path)/beanshell/bsh-[version].jar Compile it, done!

PS: Python and Lua are precompiled and already put in res/raw folder. You don't need to setup the cross compile environment unless you want to also compile Lua and Python yourself.

· One min read

基於 Android 平台擴充,支援 MPEG-4 外接 FullHD 顯示器播放的手持設備(不是手機

· 2 min read

這篇完整講解了 Python Unicode 的作法,

例如為什麼都已經是 Unicode 了還會有 encode, decode 的需求? 答案是因為電腦內部以二進制儲存 Unicode, 而一般網頁等程式能處理的是經過 "文字編碼" 後的 text code (utf-8, big5, gbk).

而為什麼常看到 UTF-8? 因為 UTF-8 這套文字編碼相容英文最常用的 ASCII 文字編碼,所以大多數英文程式不需要改寫就能沿用.

所以從網頁 / 程式存中文到資料庫 (電腦) 時要做 data.encode ('big5') 的動作來存到電腦中.

h = ' 哈囉 ' h '\xab\xa2\xc5o'

從電腦中取出的中文 data 要做 data.decode ('big5') 的動作,

print h 哈囉 h.decode ('big5') u'\u54c8\u56c9' print h.decode ('big5') 哈囉

那麼為什麼有時候用一些程式不需要自己處理這些事情呢? 那是因為這些程式的作者已經預幫你處理了 XD

不知道預設的編碼時,可以試試用 Universal Encoding Detector 來猜測所使用的編碼.

Update: