cannorin / FSharp.CommandLine

A framework for building command line application in F#
Apache License 2.0
57 stars 1 forks source link

Cannot parse hex values #2

Closed thomasd3 closed 4 years ago

thomasd3 commented 4 years ago

The following:

sscanf "%x" "1234abc"

will give:

Unhandled Exception format failure "1234abc" at Microsoft.FSharp.Core.PrintfModule.PrintFormatToStringThenFail@1637.Invoke(String message) in F:\workspace.1_work\1\s\src\fsharp\FSharp.Core\printf.fs:line 1637 at FSharp.Scanf.value$cont@318[t](FSharpList1 matches, FSharpList1 formatters, Unit unitVar) at FSharp.Scanf.ksscanf[a,b,c,d,t,u](PrintfFormat5 pf, FSharpFunc2 cont, String s) at <StartupCode$FSI_0027>.$FSI_0027.main@()

it looks like %x gets mapped at as an int32 but there is no conversion happening.

cannorin commented 4 years ago

This part seems to be broken: https://github.com/cannorin/FSharp.CommandLine/blob/master/src/FSharp.Scanf/scanf.fs#L49-L50. It should be fun c -> Char.IsLower c || Char.IsDigit c. I will try this tomorrow (I'm a bit busy right now), but if you have time you can freely send a PR.