I’m new to ruby and android. I come from a Java background. I’m going
to attempt to create an android/ruby application to interface with my
microcontroller (Adruino Uno). Is this even possible with Ruby? I
recently discovered Ruboto, but not sure if it has the capability to
access the usb/serialport on the android device (mobile phone).
I also found the serialport gem, which I think can be used to access
serialports on my computer, but not sure if it would work on my android
device.
I’m running into a problem trying to read a line of text that has some
multibyte
characters gsub is failing. Is there a trick to finding and replacing
multibyte
characters?
The multibyte characters look like this in a text editor:
When simple_soft_en = 1, this registers contents are transmitted to the
remote
PHY in DME format.
When I put this into irb, this is what that text looks like:
1.9.3-p194 :001 > theText = “When simple_soft_en = 1, this
register\U+FFC3\U+FFADs contents are transmitted to the remote PHY in
DME
format.”
=> “When simple_soft_en = 1, this registers contents are transmitted to
the
remote PHY in DME format.”
I’m running into a problem trying to read a line of text that has some multibyte
characters gsub is failing. Is there a trick to finding and replacing multibyte
characters?
Do you have something like this as the first line of your code?
I’m running into a problem trying to read a line of text that has some
multibyte
characters gsub is failing. Is there a trick to finding and replacing multibyte
characters?
Do you have something like this as the first line of your code?
encoding: UTF-8
I have added this but when I do, I end up with
'gsub!: Invalid byte sequence in UTF-8 (ArgumentError).
Ironically if I use macruby’s irb, I can do the gsub without any
problems.
Why would macruby allow this, but not the MRI version of Ruby?
I did have to open the problem file in a hex editor to verify the hex
character that was causing issues, but forcing the encoding in the MRI
seemed to do the trick.
I wonder why macruby didn’t have this sort of issue though.
You might want to ask on the JRuby list or a Ruboto list (if there is
one). My understanding though is that Ruboto gives you access to most
of the features Java gives you access to in Android. If not, you might
have more luck with Mirah (created by the creator of JRuby), which has
Ruby-like syntax but is static and compiles directly down to Java
bytecode.
I’m running into a problem trying to read a line of text that has some
multibyte
characters gsub is failing. Is there a trick to finding and replacing
multibyte
characters?
I’m new to ruby and android. I come from a Java background. I’m going
to attempt to create an android/ruby application to interface with my
microcontroller (Adruino Uno). Is this even possible with Ruby? I
recently discovered Ruboto, but not sure if it has the capability to
access the usb/serialport on the android device (mobile phone).
Ruboto gives you access to the complete Android API, so if a Java
Android app can access the serial port, so can a Ruboto Android app.
You might want to ask on the JRuby list or a Ruboto list (if there is
one). My understanding though is that Ruboto gives you access to most
of the features Java gives you access to in Android. If not, you might
have more luck with Mirah (created by the creator of JRuby), which has
Ruby-like syntax but is static and compiles directly down to Java
bytecode.