Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing "String.unescaped" #3888

Closed
vicuna opened this issue Nov 23, 2005 · 7 comments
Closed

Missing "String.unescaped" #3888

vicuna opened this issue Nov 23, 2005 · 7 comments
Assignees

Comments

@vicuna
Copy link

vicuna commented Nov 23, 2005

Original bug ID: 3888
Reporter: @mmottl
Assigned to: @lefessan
Status: closed (set by @xavierleroy on 2015-12-11T18:04:34Z)
Resolution: fixed
Priority: normal
Severity: feature
Version: 3.09.0
Fixed in version: 3.13.0+dev
Category: ~DO NOT USE (was: OCaml general)
Monitored by: @ygrek scientician

Bug description

It is funny that there is a "String.escaped" function but not the inverse "String.unescaped", which makes the escaping function pretty useless.

Could you please add this missing function to the String-module? Thanks!

Btw., there is a "map"-function in the String-module. Why not expose it in the interface?

Best regards,
Markus

@vicuna
Copy link
Author

vicuna commented Nov 24, 2005

Comment author: anonymous

I think you're looking for Token.eval_string. (Of course that's not to say that the same function shouldn't be added to the string module... It's highly illogical that it isn't there.)

@vicuna
Copy link
Author

vicuna commented Jan 4, 2012

Comment author: gerd

Funny enough it actually exists in some form:

let unescape s =
Scanfs.sscanf (""" ^ s ^ """) "%S" (fun u -> u)

So I guess it is only a matter of exporting it.

@vicuna
Copy link
Author

vicuna commented Jan 5, 2012

Comment author: @ygrek

shouldn't it be "%S%!" ?

@vicuna
Copy link
Author

vicuna commented Jan 5, 2012

Comment author: gerd

@ygrek: I thought the end of input was already marked enough by the enclosing double quotes. But this can in deed make a difference for recognizing invalid s, e.g. s=""". So better use your format string.

@vicuna
Copy link
Author

vicuna commented Jan 8, 2012

Comment author: @lefessan

I have added Scanf.unescaped and String.map in the SVN. I will close this bug report if there is no complain about them.

@vicuna
Copy link
Author

vicuna commented Jan 8, 2012

Comment author: @ygrek

I guess it is impossible to put it in String module without creating circular dependency?

@vicuna
Copy link
Author

vicuna commented Jan 9, 2012

Comment author: @lefessan

Indeed, the other solution would be to re-implement it completely in String, and it is not really worth adding 30 lines of code (1/6 of string.ml) for that, when it is available as one line in Scanf.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants