Prevent `IndexOf` from matching the full-width "?" looking for the half-width "?" when LC_ALL is "ja.UTF-8"

  c#, docker

source code:

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(DateTime.Now.ToString());
            Console.WriteLine("Hello World!");
            Console.WriteLine("aaa?".IndexOf("?", 1 - 1) + 1);
            Console.WriteLine("aaa?".IndexOf("?", 1 - 1) + 1);
            Console.WriteLine("aaa?".IndexOf("?", 1 - 1) + 1);
            Console.ReadLine();
        }
    }
}

Dockerfile:

FROM mcr.microsoft.com/dotnet/aspnet:3.1.10 AS base
RUN apt-get update 
    && DEBIAN_FRONTEND=noninteractive apt-get install -y locales tzdata libc6-dev libgdiplus 
    && dpkg-reconfigure --frontend=noninteractive locales 
    && echo "Asia/Tokyo" > /etc/timezone 
    && rm -rf /etc/localtime 
    && dpkg-reconfigure --frontend=noninteractive tzdata 
    && rm -rf /var/lib/apt/lists/*
ENV LC_ALL ja.UTF-8

WORKDIR /app

FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build
WORKDIR /src
COPY ["ConsoleApp1/ConsoleApp1.csproj", "ConsoleApp1/"]
RUN dotnet restore "ConsoleApp1/ConsoleApp1.csproj"
COPY . .
WORKDIR "/src/ConsoleApp1"
RUN dotnet build "ConsoleApp1.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "ConsoleApp1.csproj" -c Release -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "ConsoleApp1.dll"]

[email protected]:/home/ubuntu/dotnet/ConsoleApp1# docker run goolsdu/test:v1
11/27/2020 23:27:23
Hello World!
0
4
0

[email protected]:/home/ubuntu/dotnet/ConsoleApp1# docker run goolsdu/test:v2
2020/11/27 23:30:33
Hello World!
4
4
4

The need now is to turn the LC_TIME format of docker image into YYYY/MM/DD, but find "aaa? ". IndexOf ("?", 1 – 1) results incorrectly, and the half question mark does not have the string "aaa?" "In, but the result of execution is 4, how to solve it?" Please help me

Source: Docker Questions

LEAVE A COMMENT