Utf8.smali 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. .class public final Lokio/Utf8;
  2. .super Ljava/lang/Object;
  3. .source ""
  4. # direct methods
  5. .method private constructor <init>()V
  6. .locals 0
  7. invoke-direct {p0}, Ljava/lang/Object;-><init>()V
  8. return-void
  9. .end method
  10. .method public static size(Ljava/lang/String;)J
  11. .locals 2
  12. invoke-virtual {p0}, Ljava/lang/String;->length()I
  13. move-result v0
  14. const/4 v1, 0x0
  15. invoke-static {p0, v1, v0}, Lokio/Utf8;->size(Ljava/lang/String;II)J
  16. move-result-wide v0
  17. return-wide v0
  18. .end method
  19. .method public static size(Ljava/lang/String;II)J
  20. .locals 9
  21. if-eqz p0, :cond_b
  22. if-ltz p1, :cond_a
  23. if-lt p2, p1, :cond_9
  24. invoke-virtual {p0}, Ljava/lang/String;->length()I
  25. move-result v0
  26. if-gt p2, v0, :cond_8
  27. const-wide/16 v0, 0x0
  28. :goto_0
  29. if-ge p1, p2, :cond_7
  30. invoke-virtual {p0, p1}, Ljava/lang/String;->charAt(I)C
  31. move-result v2
  32. const/16 v3, 0x80
  33. const-wide/16 v4, 0x1
  34. if-ge v2, v3, :cond_0
  35. add-long/2addr v0, v4
  36. :goto_1
  37. add-int/lit8 p1, p1, 0x1
  38. goto :goto_0
  39. :cond_0
  40. const/16 v3, 0x800
  41. if-ge v2, v3, :cond_1
  42. const-wide/16 v2, 0x2
  43. :goto_2
  44. add-long/2addr v0, v2
  45. goto :goto_1
  46. :cond_1
  47. const v3, 0xd800
  48. if-lt v2, v3, :cond_6
  49. const v3, 0xdfff
  50. if-le v2, v3, :cond_2
  51. goto :goto_5
  52. :cond_2
  53. add-int/lit8 v6, p1, 0x1
  54. if-ge v6, p2, :cond_3
  55. invoke-virtual {p0, v6}, Ljava/lang/String;->charAt(I)C
  56. move-result v7
  57. goto :goto_3
  58. :cond_3
  59. const/4 v7, 0x0
  60. :goto_3
  61. const v8, 0xdbff
  62. if-gt v2, v8, :cond_5
  63. const v2, 0xdc00
  64. if-lt v7, v2, :cond_5
  65. if-le v7, v3, :cond_4
  66. goto :goto_4
  67. :cond_4
  68. const-wide/16 v2, 0x4
  69. add-long/2addr v0, v2
  70. add-int/lit8 p1, p1, 0x2
  71. goto :goto_0
  72. :cond_5
  73. :goto_4
  74. add-long/2addr v0, v4
  75. move p1, v6
  76. goto :goto_0
  77. :cond_6
  78. :goto_5
  79. const-wide/16 v2, 0x3
  80. goto :goto_2
  81. :cond_7
  82. return-wide v0
  83. :cond_8
  84. new-instance p1, Ljava/lang/IllegalArgumentException;
  85. new-instance v0, Ljava/lang/StringBuilder;
  86. invoke-direct {v0}, Ljava/lang/StringBuilder;-><init>()V
  87. const-string v1, "endIndex > string.length: "
  88. invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  89. invoke-virtual {v0, p2}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;
  90. const-string p2, " > "
  91. invoke-virtual {v0, p2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  92. invoke-virtual {p0}, Ljava/lang/String;->length()I
  93. move-result p0
  94. invoke-virtual {v0, p0}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;
  95. invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
  96. move-result-object p0
  97. invoke-direct {p1, p0}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V
  98. throw p1
  99. :cond_9
  100. new-instance p0, Ljava/lang/IllegalArgumentException;
  101. new-instance v0, Ljava/lang/StringBuilder;
  102. invoke-direct {v0}, Ljava/lang/StringBuilder;-><init>()V
  103. const-string v1, "endIndex < beginIndex: "
  104. invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  105. invoke-virtual {v0, p2}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;
  106. const-string p2, " < "
  107. invoke-virtual {v0, p2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  108. invoke-virtual {v0, p1}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;
  109. invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
  110. move-result-object p1
  111. invoke-direct {p0, p1}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V
  112. throw p0
  113. :cond_a
  114. new-instance p0, Ljava/lang/IllegalArgumentException;
  115. new-instance p2, Ljava/lang/StringBuilder;
  116. invoke-direct {p2}, Ljava/lang/StringBuilder;-><init>()V
  117. const-string v0, "beginIndex < 0: "
  118. invoke-virtual {p2, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  119. invoke-virtual {p2, p1}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;
  120. invoke-virtual {p2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
  121. move-result-object p1
  122. invoke-direct {p0, p1}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V
  123. throw p0
  124. :cond_b
  125. new-instance p0, Ljava/lang/IllegalArgumentException;
  126. const-string p1, "string == null"
  127. invoke-direct {p0, p1}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V
  128. goto :goto_7
  129. :goto_6
  130. throw p0
  131. :goto_7
  132. goto :goto_6
  133. .end method