Created
November 16, 2020 22:50
-
-
Save gr33n7007h/1ee53ec23cbb931e5a14c57c5fa94c14 to your computer and use it in GitHub Desktop.
Testing variadic Fiddle version 1.0.1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'fiddle' | |
include Fiddle | |
# Fiddle v:1.0.1 | |
setlocale = Function.new( | |
Handle['setlocale'], | |
[ | |
:int, | |
:const_string | |
], | |
:voidp | |
) | |
setlocale.(4, '') | |
strfmon = Function.new( | |
Handle['strfmon'], | |
[ | |
:voidp, | |
:size_t, | |
:const_string, | |
:variadic | |
], | |
:ssize_t | |
) | |
buf = Pointer.malloc(100) | |
strfmon.( | |
buf, | |
buf.size, | |
'%n :: %i', | |
:double, | |
42.1337, | |
:double, | |
42.1337 | |
) | |
p buf.to_s.force_encoding('utf-8') | |
free buf | |
__END__ | |
"£42.13 :: GBP42.13" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment