Skip to content

Commit d93c956

Browse files
committed
expanded warning for Int<->Char conversion
1 parent cb3dbde commit d93c956

File tree

2 files changed

+13
-6
lines changed
  • core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api
  • docs/StardustDocs/topics

2 files changed

+13
-6
lines changed

core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/convert.kt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,10 @@ internal interface ConvertDocs {
132132
* * [LocalDateTime], [LocalDate], [LocalTime],
133133
* `Instant` ([kotlinx.datetime][DeprecatedInstant], [kotlin.time][StdlibInstant], and [java.time]),
134134
* * [URL], [IMG], [IFRAME].
135+
*
136+
* __NOTE__: Conversion between [Int] and [Char] is done by UTF-16 [Char.code].
137+
* To convert [Char]->[Int] the way it is written, use [parse()][parse] instead, or,
138+
* in either case, use [String] as intermediary type.
135139
*/
136140
interface SupportedTypes
137141

@@ -362,7 +366,7 @@ public class Convert<T, out C>(
362366
* preserving their original names and positions within the [DataFrame].
363367
*
364368
* The target type is provided as a reified type argument.
365-
* For the full list of supported types, see [ConvertDocs.SupportedTypes].
369+
* For the full list of supported types, see [SupportedTypes][ConvertDocs.SupportedTypes].
366370
*
367371
* For more information: {@include [DocumentationUrls.Convert]}
368372
*
@@ -390,7 +394,7 @@ public class Convert<T, out C>(
390394
* preserving their original names and positions within the [DataFrame].
391395
*
392396
* The target type is provided as a [KType].
393-
* For the full list of supported types, see [ConvertDocs.SupportedTypes].
397+
* For the full list of supported types, see [SupportedTypes][ConvertDocs.SupportedTypes].
394398
*
395399
* For more information: {@include [DocumentationUrls.Convert]}
396400
*
@@ -554,7 +558,7 @@ public inline fun <T, C, reified R> Convert<T, C>.perRowCol(
554558
*
555559
* The target type is provided as a reified type argument.
556560
*
557-
* For the full list of supported types, see [ConvertDocs.SupportedTypes].
561+
* For the full list of supported types, see [SupportedTypes][ConvertDocs.SupportedTypes].
558562
*
559563
* @param [C] The target type to convert values to.
560564
* @return A new [DataColumn] with the values converted to type [C].
@@ -564,7 +568,7 @@ public inline fun <reified C> AnyCol.convertTo(): DataColumn<C> = convertTo(type
564568
/**
565569
* Converts values in this column to the specified [type].
566570
*
567-
* For the full list of supported types, see [ConvertDocs.SupportedTypes].
571+
* For the full list of supported types, see [SupportedTypes][ConvertDocs.SupportedTypes].
568572
*
569573
* @param type The target type, provided as a [KType], to convert values to.
570574
* @return A new [DataColumn] with the values converted to [type].

docs/StardustDocs/topics/convert.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,11 @@ df.convert { name }.asColumn { col ->
7373
* `Instant` (kotlinx.datetime, kotlin.time, and java.time)
7474
* `enum` classes (by name)
7575

76-
Note that converting between `Char` and `Int` is done by ASCII character code.
77-
This means the `Char` `'1'` becomes the `Int` `49`.
76+
> Note that converting between `Char` and `Int` is done by UTF-16 character code.
77+
> This means the `Char` `'1'` becomes the `Int` `49`.
78+
> To convert `Char -> Int` the way it is written, use `parse()` instead, or,
79+
> in either case, use `String` as intermediary type.
80+
> {style="warning"}
7881
7982
If you want to convert `Char` `'1'` to the `Int` `1`, use [parse()](parse.md) instead, or use `String`
8083
as intermediate type.

0 commit comments

Comments
 (0)