English 中文(简体)
在试图将str改成乙 as时,不要.。
原标题:Getting java.lang.NumberFormatException when trying to convert string to ascii
  • 时间:2024-01-07 17:52:13
  •  标签:
  • scala
  • ascii

我试图用“.toInt”将其体力转换到其体力当量,我一再发现这一错误:

java.lang.NumberFormatException: For input string: " _ "
  java.lang.NumberFormatException.forInputString(NumberFormatException.java:67)
  java.lang.Integer.parseInt(Integer.java:654)

This is the line it is failing at:

P.map[Expression]{ case y => Chrc(y.toInt)}

Chrc is a parser that returns a string.

我曾尝试过这样做。

val x =  _ 
println(x.toInt) 

在法典的编外,我写了字,并做了工作,因此,问题在于这一句,以及我试图将它改变为Chrc类内部的愤怒。 是否有另一种方式来撰写?

问题回答

问题重新提出如下:

scala> val x = " _ "
val x: String =  _ 
                                                                                                    
scala> x.toInt
java.lang.NumberFormatException: For input string: " _ "
  at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:67)
  at java.base/java.lang.Integer.parseInt(Integer.java:654)
  at java.base/java.lang.Integer.parseInt(Integer.java:786)
  at scala.collection.StringOps$.toInt$extension(StringOps.scala:908)
  ... 32 elided

此处为<条码>x。 这不同于你提供的法典:

scala> val x =  _ 
val x: Char = _
                                                                                                    
scala> x.toInt
val res1: Int = 95

www.un.org/spanish/ga/president

Scala和Java的特性是,Char 的类型(在Java,char,加上一个小的c,是一种分类,因此,toInt使你具有特性的ASCII数值,而不是加以分类。

我完全可以理解你的代码,因为Im在 Java没有进步,但我很相信你能够使用<条码>(int)特性;投放。 !! 因此,在您的简短例子中,可使用<条码>x。





相关问题
Percent Encoded UTF-8 to Ascii(8-bit) conversion

Im reading in urls and they often have percent encoded characters. Example: %C3%A9 is actually é According to http://www.microsystools.com/products/sitemap-generator/faq/character-percentage-url-...

US-ASCII encoding with Odd and Even numbers?

I splitted the list of numbers 1-100 to files of 2 bytes. Then, I noticed that each odd number btw 11-99 needs 2 files, ie 4bytes, while each even number btw 11-99 needs 1 file, 2bytes. A file is ...

Issues with Chr(0) in SQL INSERT script

We currently use the SQL Publishing Wizard to back up our database schemas and data, however we have some database tables with hashed passwords that contain the null character (chr(0)). When SQL ...

Encoding a string to ascii

I have a long string that I want to encode to ascii. I m doing: s = s.encode( ascii , replace ) but I get: ascii codec can t decode byte 0xc3 in position 2646: ordinal not in range(128) (I ve ...

热门标签