Framework Asiatant and Unicode source

BlitzMax Forums/BlitzMax Programming/Framework Asiatant and Unicode source

popcade(Posted 2006) [#1]
It seems FA is not unicode-aware(yet), personally I don't take it as problem, however sometime it can't correctly figures the modeles in the source so I found this little drawback.

Will it get updated with support like this?


Dreamora(Posted 2006) [#2]
Erm
Does the BM compiler accept unicode?
I thought sources are fixed to english alpha numerics + a few extra signs?


popcade(Posted 2006) [#3]
Yes, it's ok to use unicode in the source, and the output will work.

Not very important feature, this just came up when i want to scan a source that coded in BLIde.


Hotcakes(Posted 2006) [#4]
Proper unicode support is very important in a multiplatform/multilingual environment.


ziggy(Posted 2006) [#5]
You can dissable unicode subformat in BLIde, in the preferences dialog if you're using 0.7.52, The current BLIde beta version saves to ANSI, unless unicode is needed (then saves to Unicode).

I wrote to the FA author about a month to tell him about the unicode issue in FA, he told me he will arrange it.


EOF(Posted 2006) [#6]
Hi ziggy,
Got any info on how to get to BlitzMax to read/convert UTF via ReadLine$()?


popcade(Posted 2006) [#7]
http://www.blitzbasic.com/Community/posts.php?topic=57686#641596

Maybe this may help(a little), FA is a must-have tool for BMaxers, the unicode support will be pretty useful for multilanguage developers.


ziggy(Posted 2006) [#8]
@Jim Brown. You have to use textstream, and enable the correct encoding. fore more info on how to detect encoding, you can see the loadtext function in the blitzmax modules, it's a very easy to understand function, and works like a charm loading unicode or ansi encoded files.
i made a little module to read streams ecognizing the encoding, base on the loadtext function:

Type TextFileReader
	Function CreateStream:TTextStream(url:Object,DetectEncoding:Int = True,ForceEncoding:Int = 0 )
		Local Stream:TStream=ReadStream(url) 'This is the base stream
		Local TxStream:TTextStream
		If Stream = Null Then Return Null 'Unable to open URL
		If detectencoding = False Then
			TxStream = TTextStream.Create( Stream,forceencoding)
			Return TxStream
		Else
			TxStream = TTextStream.Create( Stream,EncodingDetector(url))
			Return TxStream
		EndIf
		
	End Function
	Function EncodingDetector:Int(url:Object)
		Local format:Int = 1  'This is to store the encoding, by default LATIN1
		Local Stream:TStream=ReadStream(url) 'This is the base stream
		If not Stream.Eof() 'check if there is data to read
			Local c:Byte=Stream.ReadByte()
			If not Stream.Eof()
				Local d:Byte=Stream.ReadByte()  'Get the firt byte to get the encoding
				If c=$fe and d=$ff  'if its FF and FE (Big endian byte order)
					format=TTextStream.UTF16BE
				Else If c=$ff and d=$fe  'Little endian byte order
					format=TTextStream.UTF16LE
				Else If c=$ef and d=$bb
					If not Stream.Eof()
						Local e:Byte=Stream.ReadByte()
						If e=$bf format=TTextStream.UTF8
					EndIf
				EndIf
			EndIf
		EndIf
		If format = 1
   			 Try
        				Stream.Seek(0) 'this will only work on an unbuffered serial stream
    			Catch err$
    			End Try
  		EndIf


		Return format
	End Function
End Type


making something as simple as:

Local pepe:TTextStream = TextFileReader.CreateStream("file.txt")

will create an apropiate text stream, with the correct encoding. (it will not work for non local files (internet or whatever))


EOF(Posted 2006) [#9]
Great.
Can you guys throw a couple of unicode *.bmx files my way so I can run some tests?


popcade(Posted 2006) [#10]
Such file can be generated by opening some source in MaxIDE, type some Chinese/Japanese in, and it'll get converted in to unicode encoded files automatically.


EOF(Posted 2006) [#11]
Please give the latest version of Framework Assistant a test.
I have hopefully added correct handling of unicode files.
Let me know if it works.


ziggy(Posted 2006) [#12]
It works like a charm. :D
Could it be possible to let Framewrok Assistant receive a bmx filename in it's command args and analize the file automaticaly? This would it make it possible to integrate the Framework Assistant as a BLIde Add-On, wich may be great for me, and for all the BLIde users.

Please, take it in consideration.
Thanks a lot, your assistant is helping me a lot.


popcade(Posted 2006) [#13]
It works correctly on my available projects, thanks :)


EOF(Posted 2006) [#14]
Great. Glad it works.

Could it be possible to let Framewrok Assistant receive a bmx filename in it's command args and analize the file automaticaly?
Sure. Give me a couple of days ..

What about the output though?
I could still keep it as a generated HTML file or simply use Print if your IDE is capable of picking up the output.


ziggy(Posted 2006) [#15]
It would be great just to be able to launch Framework Assistant with a bmx file as a parameter. that's enough. :D

ah, and thanks!


EOF(Posted 2006) [#16]
It would be great just to be able to launch Framework Assistant with a bmx file as a parameter


Done in v2.07
Drag a file onto the icon or supply a single parameter with the path and filename for the *.bmx file to scan.
Don't forget to enclose the parameter in "" if there are spaces present in the path/filename.

Plus support for *.xml (offers Pub.maXML as module needed)

Download -> Framework Assistant


ziggy(Posted 2006) [#17]
Many thanks! it works perfect. Now I'm going to make some little fixes to BLIde. Here's a little example of what it will be possible to do with the next BLIde release:



and then you get:



I think this will be a very interesting feature, adding the feature to let the FA be available as a BLIde Add On.


EOF(Posted 2006) [#18]
Great stuff ziggy. Other ideas for add-on tools ..

A couple of these are from PureBasic but it'll only take a little effort to write Max versions:




ziggy(Posted 2006) [#19]
Great but... what does this do exactly?


EOF(Posted 2006) [#20]
Not sure if your Blide already has any of these features but ..

Color Picker
============
The color picker for example would let you to select a color, then copy something like $fa,$35,$01 into the clipboard so you can copy/paste it into your code for SetColor and SetClsColor commands.

NumCoverter
===========
I used this so that I could rewrite values from decimal to hex.

Structure Viewer
================
Probably overkill for Max but the PB structure viewer lets you examine how the type structs are defined. Just for quick reference really. However, in max you can simply click a command/function, hit F1 twice, scroll to the top of the help page and view source. So, it's not really needed.